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


in reply to What is this erroring out?

When the line return 0 if ($2 !~ /(d|p|t)/); is executed, $2 is undef because in the previous regex matching (the one in the line just above it!) has only one pair of parentheses. Use something like this (untested):

sub test { my $a = shift; my ($first, $second, $third, $fourth, $fifth) = $a =~ /(.)(.)(.)(.. +)(.+)/; return 0 if ($first !~ /(a)/); return 0 if ($second !~ /(d|p|t)/); return 0 if ($third !~ /(a|h|r|s|t)/); return 0 if ($fourth !~ /(aw|er|dd|cb|aa)/); }

--
 David Serrano
 (Please treat my english text just like Perl code, i.e. feel free to notify me of any syntax, grammar, style and/or spelling error. Thank you!).