Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
For example, sub('/turtle|fish/i') and then in the sub, I would have:
sub { # After validating that the regex is really a regex. my $string = 'fish'; print "hello" if ($string =~ $_[0]); # prints hello }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing regular expressions as arguments to subroutines
by johnnywang (Priest) on Nov 02, 2005 at 23:03 UTC | |
|
Re: Passing regular expressions as arguments to subroutines
by ikegami (Patriarch) on Nov 02, 2005 at 23:31 UTC | |
by ioannis (Abbot) on Nov 03, 2005 at 00:24 UTC |