in reply to Re^4: Troubleshooting question
in thread Troubleshooting question

Also I believe there already is something similar to what you are proposing in the code already:
$bkp_info = `sed -e :a -e "{$d;N;2,3ba}" -e "{P;D}" /db2/$DB2DBDFT/Mes +sages/temp.txt`;
Similar on first appearance, but fundamentally different.

As far as Perl is concerned, (and Perl goes first, then the shell, and only then it's seds turn), in the above line, $d is Perl variable. If you want to pass $d to shell you first need to protect against Perl, then against the shell. The above code does neither. In:

my $cmd = q{sed -e :a -e '{$d;N;2,3ba}' -e "{P;D}" /db2/$DB2DBDFT/Mess +ages/temp.txt}; $bkp_info = `$cmd`;
the $d to protected against both. The q{} construct makes Perl not interpolate variables (unlike the backticks). And the single quotes makes the shell not interpolate variables (unlike the double quotes).