Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!sun-barr!newstop!texsun!convex!newsadm From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: pattern match strangeness Message-ID: <1991Apr11.074119.26116@convex.com> Date: 11 Apr 91 07:41:19 GMT References: <1991Apr11.011752.9372@sctc.com> Sender: newsadm@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Distribution: na Organization: CONVEX Software Development, Richardson, TX Lines: 45 Nntp-Posting-Host: pixel.convex.com From the keyboard of scott@sctc.com (Scott Hammond): :When $s is set to "", the program below says: : :match, s= :no match : :Both matches work for a non-null $s. : :Am I doing this wrong? i think so. :#!/usr/local/bin/perl : :$s = ""; : :$pat = "/est/"; : :if ($s =~ eval $pat) right here is the error: /est/ evals to null or 1, depending on what $_ is set to. you mean: if (eval "\$s =~ $pat") or better: $pat = 'est'; if ($s =~ /$pat/) : { print "match, s= $s\n"; } : :else : : { print "no match\n"; } : :if ($s =~ /est/) : : { print "match, s= $s\n"; } : :else : : { print "no match\n"; } --tom