Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

lower case

by Anonymous Monk
on Feb 18, 2000 at 19:16 UTC ( [id://3685]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

how do i make $var="Bob"; match for "bob"? thanks, steve

Replies are listed 'Best First'.
Re: lower case
by Anonymous Monk on Feb 18, 2000 at 20:15 UTC
    simply: lc $var; To put it in the same var: $var = lc $var;
Re: lower case
by btrott (Parson) on Feb 18, 2000 at 22:57 UTC
    The fact that you said "match" sounds like you're talking about a regular expression... is that the case? If so, you can just say
    if ($var =~ /bob/i) { # Bob matches bob }
    Or, as the previous poster said, if you're just trying to compare two strings case-insensitively, use
    if (lc $var eq "bob") { # Bob matches bob }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://3685]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-03-28 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found