Do you know where your variables are? | |
PerlMonks |
Re^2: Passing regular expressions as arguments to subroutinesby ioannis (Abbot) |
on Nov 03, 2005 at 00:24 UTC ( [id://505186]=note: print w/replies, xml ) | Need Help?? |
The only reason the subroutine must only accept a regex is because
that is the requirement imposed by the problem. Without such restriction, the
subroutine could also accept a string (in which case, one easy
way to validate would likely involve an eval() ).
The code, $string =~ $re ;, will work in both cases:
In Section
Seekers of Perl Wisdom
|
|