Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I'm trying to get a regular expression to pass the results of a regular expression substitution into a method argument.
Rather than just make a temporary variable and do the substitution on that, and then pass that to the function, is there any way I can do the substitution as part of the argument list, eg:
I want to keep the blah method as general as possible, and don't want to add the regular expression there. This is purely a style issue (as I think something like this would look much nicer than having to use one-off variables)$word = 'BLAHBLAH'; print blah(s/BLAH/COW/); print "$word\n"; sub blah { my $stuff = shift; print "$stuff\n"; }
Back to
Seekers of Perl Wisdom