Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: variable comparison

by perlcgi (Hermit)
on May 25, 2000 at 17:47 UTC ( #14745=note: print w/replies, xml ) Need Help??


in reply to variable comparison

$file="filename.txt"; $ext=".txt"; if ($file =~ /$ext$/){ print "match\n"} else {print "nomatch\n"}

Replies are listed 'Best First'.
RE: Re: variable comparison
by merlyn (Sage) on May 25, 2000 at 18:03 UTC
    Nope. That finds "Xtxt" because you aren't escaping the dot. Moral: don't use regex when a literal match will do, or learn about \Q.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2022-12-09 03:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?