The prints aren't in a loop, so why would it print before/after every line?
perl -e 'while (<>) { print "XXX\n" ;print; print "XXX" }'
Or use -n
perl -ne 'print "XXX\n" ;print; print "XXX"'
Or even -p
perl -pe '$_ = "XXX\n" . $_ . "XXX"'
Then there's the useless use of cat. cat filename is a waste of resource. Use "<" instead.
perl -e'...' < /tmp/file
Or since <> (including -n and -p) treats the arguments as files to read, just
perl -e'...' /tmp/file
All together:
perl -pe '$_ = "XXX\n" . $_ . "XXX"' /tmp/file
In reply to Re: pipe output to perl
by ikegami
in thread pipe output to perl
by spmlingam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |