in reply to hex code passed from command line is interpreted literally in substitution
If you have to call it often (thousands of times), you can simply wrap it in a sub to compile it. $_ can simply represent the sub's parameter.
my $perl = shift; $code = eval "sub { local \$_ = shift; $perl; return $_ }" or die "Syntax error: $@"; foreach my $var (@lots_of_data) { $var = $code->($var) }
And in the end, you give the user the option to pass in other code than just a simple s///. This is something that the module File::Rename does, for example, a command line utility to rename files where you can define how the file name should be named in a Perl snippet that changes the value of $_ (the file name).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hex code passed from command line is interpreted literally in substitution
by Allasso (Monk) on Mar 06, 2011 at 00:03 UTC | |
|
Re^2: hex code passed from command line is interpreted literally in substitution
by Allasso (Monk) on Mar 09, 2011 at 22:39 UTC | |
by Anonymous Monk on Mar 10, 2011 at 03:05 UTC | |
by Allasso (Monk) on Mar 10, 2011 at 12:41 UTC | |
by Anonymous Monk on Mar 10, 2011 at 14:14 UTC | |
by Allasso (Monk) on Mar 10, 2011 at 14:38 UTC | |
|