in reply to Command Line Arg contains Variable and more
I had a feeling the "eval" would be needed,
If your argument was Perl code, sure.
$ perl -e' my $host = "localhost"; eval $ARGV[0]; ' 'system("echo", $host)' localhost
But your argument is a shell command. That means you'll need to parse the argument as if it was a shell command an interpolate the appropriate variables.
It would be easier to use a template.
$ perl -MTemplate -e' Template->new()->process( \$ARGV[0], { host => "localhost" }, \my $cmd ); system($cmd) ' 'echo [% host %]' localhost
|
|---|