RE: lc
From: Rob Hanson (rhanson_at_aptegrity.com)
Date: 02/20/04
- Next message: WilliamGunther_at_aol.com: "Re: lc"
- Previous message: Stuart White: "lc"
- Maybe in reply to: Stuart White: "lc"
- Next in thread: Stuart White: "RE: lc"
- Reply: Stuart White: "RE: lc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: 'Stuart White' <poovite@yahoo.com>, Perl Beginners Mailing List <beginners@perl.org> Date: Fri, 20 Feb 2004 17:29:57 -0500
> then I tried this:
> lc($input);
> and I got the same error.
This shouldn't give an error. ...It didn't give me one.
> so I tried this:
> lc(chomp($input = <STDIN>)));
> and I got an error message that said I couldn't use lc
> in that way - or something like that.
The exact error would be helpful.
This won't work though because chomp() returns the number of newline
characters removed from the string... so in essence you are trying to
lowercase the number "0" or "1" (the return value of chomp). ...Not to
mention that you lc() does not modify the scalar passed as an argument (like
chomp does), so you need to store the result of lc().
This is what you want:
chomp($input = <STDIN>);
$input = lc($input);
print $input;
Rob
-----Original Message-----
From: Stuart White [mailto:poovite@yahoo.com]
Sent: Friday, February 20, 2004 5:21 PM
To: Perl Beginners Mailing List
Subject: lc
I want to take input from <STDIN> and then convert it
to lowercase. so I tried this:
lc(chomp($input = <STDIN>)));
and I got an error message that said I couldn't use lc
in that way - or something like that. I can't
remember the message now.
then I tried this:
lc($input);
and I got the same error.
Then I checked my copy of Learning Perl and the index
pointed me to an example of lower case, but it was a
regex example, not a function. So I thought that
perhaps I had confused two different languages and
that Perl didn't have a lowercase function.
Just now I checked the man pages to see if I really
was not remembering the function for lowercase. When
I went there, sure enough, lc was there.
http://www.perldoc.com/perl5.8.0/pod/func/lc.html
The way it is described makes me think that I am using
it correctly, but Perl is telling me different.
So, am I using it incorrectly? Thanks
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
-- To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional commands, e-mail: beginners-help@perl.org <http://learn.perl.org/> <http://learn.perl.org/first-response>
- Next message: WilliamGunther_at_aol.com: "Re: lc"
- Previous message: Stuart White: "lc"
- Maybe in reply to: Stuart White: "lc"
- Next in thread: Stuart White: "RE: lc"
- Reply: Stuart White: "RE: lc"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|