http://www.perlmonks.org?node_id=1018837


in reply to Router Backup.pl failing (operator error no doubt)

G'day rmagin,

Welcome to the monastery.

The message indicating a potential "runaway multi-line" is due to the chop() statement:

$ perl -ce 'chop ($status=\Q$snmpset $oid s $rtr.cfg\Q);' Substitution pattern not terminated at -e line 1.

\Q escape sequences are terminated with \E (not another \Q) and are applied to strings (i.e. they're not standalone operators):

$ perl -ce 'chop ($status="\Q$snmpset $oid s $rtr.cfg\E");' -e syntax OK

Take a look at quotemeta for a more complete description.

toolic may well be correct in suggesting you want `...` instead of \Q...\Q; however, you may also want to escape the ASCII non-"word" characters in the return value - something like this (untested) might do what you want:

$ perl -ce 'chop ($status = quotemeta(`$snmpset $oid s $rtr.cfg`));' -e syntax OK

-- Ken