randy1234 has asked for the wisdom of the Perl Monks concerning the following question:
I'm having trouble using back-references in a Windows one-liner and hoping someone knows what I'm doing wrong.
I can use a single back-reference but as soon as I try more than one it breaks.
Environment:
> echo "abcd" | perl -nle '/(b).(d)/ && print "$1" ' b > echo "abcd" | perl -nle '/(b).(d)/ && print "$2" ' d > echo "abcd" | perl -nle '/(b).(d)/ && print "$1 $2" ' Can't open $2 : No such file or directory.
The error changed when I tried to escape the double-quotes with a backslash and a back-tick:
> echo "abcd" | perl -nle '/(b).(d)/ && print \`"$1 $2\`" ' Can't find string terminator "`" anywhere before EOF at -e line 1.
Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trouble with back-references on Windows
by poj (Abbot) on Mar 14, 2019 at 19:01 UTC | |
by randy1234 (Initiate) on Mar 14, 2019 at 19:30 UTC | |
|
Re: Trouble with back-references on Windows
by Laurent_R (Canon) on Mar 14, 2019 at 23:23 UTC |