RE: lc

From: Rob Hanson (rhanson_at_aptegrity.com)
Date: 02/20/04


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>


Relevant Pages

  • lc
    ... and I got an error message that said I couldn't use lc ... Then I checked my copy of Learning Perl and the index ... that Perl didn't have a lowercase function. ... Mail SpamGuard - Read only the mail you want. ...
    (perl.beginners)
  • Re: problems with Perl RegEx match
    ... Missing right bracket at ./LogPreProcessor_Inetprod.pl line 64, ... Perl didn't encounter it. ... when I used the following search term in google to look ... considering it's an error message from an older Perl - in newer Perls, ...
    (comp.lang.perl.misc)
  • Re: About the error message in Perl : "Missing right curly braces"
    ... Subject: About the error message in Perl: "Missing right curly ... SKY and the SKY marks are trade marks of ... track which line contains that curly brace which is causing that problem, ...
    (perl.beginners)
  • Re: "Did not find leading dereferencer" - new findings to an old puzzle
    ... to do with the "Dereferencer" error, because on the first example I ... I got that error message in the context of Perl standard ... this would not explain why the error message ... source code. ...
    (comp.lang.perl.misc)
  • Re: perl and CGI
    ... This error message is _not_ a Perl error message. ... I was just trying to figure out how perl and the web server works.. ... I have already developed a perl file to manage a web form (send the ... pointers to more information. ...
    (comp.lang.perl.misc)