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"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Passing results of a substitution to a function
by Pardus (Pilgrim) on Jan 20, 2003 at 03:38 UTC | |
Re: Passing results of a substitution to a function
by boo_radley (Parson) on Jan 20, 2003 at 03:43 UTC | |
Re: Passing results of a substitution to a function
by Coruscate (Sexton) on Jan 20, 2003 at 03:44 UTC | |
by Anonymous Monk on Jan 20, 2003 at 23:24 UTC | |
by Anonymous Monk on Jan 20, 2003 at 23:50 UTC | |
Re: Passing results of a substitution to a function
by BrowserUk (Patriarch) on Jan 20, 2003 at 12:05 UTC | |
by Anonymous Monk on Jan 20, 2003 at 23:28 UTC | |
Re: Passing results of a substitution to a function
by BrowserUk (Patriarch) on Jan 20, 2003 at 23:37 UTC | |
Re: Passing results of a substitution to a function
by jepri (Parson) on Jan 20, 2003 at 05:19 UTC |
Back to
Seekers of Perl Wisdom