in reply to $scaler inside a RegEx

It doesn't?

mikeraz@tire:~$ cat tpl #!/usr/bin/perl $criteria = "(abc|123)\$"; $teststring = "Foo walks up and says: abc"; if ( $teststring =~ /$criteria/ ) { print "it worked!\n"; } else { print "uh no, it did not\n"; } mikeraz@tire:~$ ./tpl it worked! mikeraz@tire:~$

is there more code around or between the statements?

Be Appropriate && Follow Your Curiosity

Replies are listed 'Best First'.
Re^2: $scaler inside a RegEx
by ikegami (Patriarch) on Aug 05, 2005 at 00:43 UTC
    Better yet:
    $criteria = "(abc|123)\$"; $teststring = "Foo walks up and says: abc"; if ( $teststring =~ /$criteria/ ) { print "Got $1\n"; } else { print "uh no, it did not\n"; } __END__ output ====== Got abc
    You might have an easier time at typing your regexp if you used qr// instead of double quotes:
    $criteria = qr/(abc|123)$/; ...