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


in reply to problems with backreference

\1 is a regular expression pattern that matches what the first capture captured. It makes no sense to use it outside of regular expressions as you did.

Perl script:

s/^(ISA\~.*?\~.*?\~.*?\~.*?\~.*?\~.*?\~.*?\~)(..........)(....).(\~.*) +$/$1${2}0$3$4/

Perl command:

perl -i -pe's/^(ISA\~.*?\~.*?\~.*?\~.*?\~.*?\~.*?\~.*?\~)(..........)( +....).(\~.*)$/$1${2}0$3$4/' PB385930.P0

ssh command:

ssh ... 'perl -i -pe'\''s/^(ISA\~.*?\~.*?\~.*?\~.*?\~.*?\~.*?\~.*?\~)( +..........)(....).(\~.*)$/$1${2}0$3$4/'\'' PB385930.P0'

Note the ' needed to be escaped when placed inside another ' literal.