Thanks everyone. I feel sortof like a dope since I
knew that to save the results of a function, I'd have
to save it in a variable. I just forgot in the
excitement of trying to use all the functions in the
same line.
Someone, I believe Jenda, brought up that the "useless
use of lc" was a warning,
Stuart White wrote:
> I want to take input from and then convert it
> to lowercase. so I tried this:
>
> lc(chomp($input = )));
Two things here:
1. It is pointless to lc a numerical value, and the boolean value [1 if a
newline was removed, 0 otherwise] returned from chomp will always be expre
> "Stuart" == Stuart White <[EMAIL PROTECTED]> writes:
Stuart> The way it is described makes me think that I am using
Stuart> it correctly, but Perl is telling me different.
Stuart> So, am I using it incorrectly? Thanks
You're confusing functions that return values (like lc) with functions
t
> -Original Message-
> From: Stuart White [mailto:[EMAIL PROTECTED]
> Sent: Saturday, 21 February 2004 9:21 AM
> To: Perl Beginners Mailing List
> Subject: lc
>
> I want to take input from and then convert it
> to lowercase. so I tried this:
>
> lc(chomp($input = )));
>
> and I got an
The error was:
useless use of lc in void context at line 22
I also tried this:
lc($input = );
print "$input";
> 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
From: Stuart White <[EMAIL PROTECTED]>
> I want to take input from and then convert it
> to lowercase. so I tried this:
>
> lc(chomp($input = )));
>
> 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
lc() takes a string, turns the string to lower case, and returns that. So
what you're searching for is:
chomp($input = lc());
This way, lc() function turns the input into lowercase, assigns it to the
$input scalar, and then chomps out the newline at the end. Quite efficent.
In a message dated
> 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 = )));
> 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.
Thanks to both Peter and register for answering my questions.
-- Drew.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 14, 2001 1:07 PM
To: Drew Cohan
Cc: [EMAIL PROTECTED]
Subject: Re: lc vs. tr
Using Benchmark.pm ... the answer is to use
Using Benchmark.pm ... the answer is to use lc ... if you flip through to the
Perl Cookbook pg 19 or receipe 1.9 you will find that tr is the wrong way to
do changing of case (or at least tr/A-Z/a-z/ since it will miss accented
characteers and so on..)
THe reason you are getting the error is beca
At 11:59 AM 8/14/01 -0400, Drew Cohan wrote:
>1. Any opinions on which is better to convert characters into lowercase
>(efficiency, speed, etc)?
>
>lc vs. tr /A-Z/a-z/ ?
lc can handle locales where upper and lower case isn't the same as A-Z vs a-z.
>2. Is there an option to tell tr to ignore
11 matches
Mail list logo