in reply to $1 trap

Well, for one, you should only trust $1 if your regex suceeds. Remember, the $1..$x variables are set after each successful regex with capturing parantheses. However, they are not cleared when a regex doesn't match. You could put the return statements in an if-block. Even better, check out this code. No $1 to worry about.

print BLAH::chg("word", qr/(\d)/); # print "nope" "2" =~ /(2)/; print BLAH::chg("word", qr/(\d)/); # print "nope" print BLAH::chg("3", qr/(\d)/); # print "yes" + package BLAH; sub chg { return $_[0] =~ $_[1] ? "yes\n" : "nope\n"; } # Alternatively, you can do: # # if($_[0] =~ $_[1]) # { # return "yes\n"; # } # return "nope\n"; __OUTPUT__ nope nope yes

HTH