I often use autosplit Perl instead of shorthand on the command line. I ended up in a case where I have many gaps that I need to keep. According to the document, the separator I need to specify is / /because things like ' 'emulate awk behavior, stripping leading spaces, etc.
My problem is the inability to specify a template / /on the command line. I tried to quote it in different ways, but the splitting ends with a slash:
perl -F'/ /' -lane 'print "@F[3..$#F]"' input.txt
The following works as expected:
perl -lne '@ar = split / /; print "@ar[3..$#ar]"' input.txt
Why is my auto-extension not working and how to fix it?
Perl 5.8.8 on RHEL 5.9.
source
share