in reply to Re: hex code passed from command line is interpreted literally in substitution
in thread hex code passed from command line is interpreted literally in substitution

well the method I mentioned fell apart when trying to pass $1, $2 etc to be interpolated as captures, so you and ikegami are right, it really needs an eval. I did want to stick with the script 'pattern' 'replacement' format however (rather than script 's/pattern/replacement/') so I used this instead:
#!/usr/bin/perl -wl use strict; my ($arg_1, $arg_2) = @ARGV; $_ = "apples"; my $expr = "s/".$arg_1."/".$arg_2."/"; eval $expr; print; ------- ./test.pl '\x61(.*)\x73' '\x41$1\x53' AppleS

Replies are listed 'Best First'.
Re^3: hex code passed from command line is interpreted literally in substitution
by Anonymous Monk on Mar 10, 2011 at 03:05 UTC
    Now give your program these magic arguments "destroyer" "`rm -rf \x2f `"
      Yeah, so it replaces the string "destroyer" with the string "`rm -rf \x2f `". So what?
        No it doesn't, it executes rm -rf /

        Hopefully, you're not running as root, you're using taint