http://qs321.pair.com?node_id=14745


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.