M
Markus Dehmann
I just found the answer to my own problem. I'm gonna share this so
people can find it via google:
I have a data file that contains blocks of data, separated by empty
lines:
line1
line2
line1
line2
Now I want to read it on the command line, one block at a time. But
perl -pe '...' reads only single lines.
The answer is: Use -00
So, this:
perl -00 -ne 'chomp; print "<BLOCK>$_</BLOCK>\n"' data.txt
Prints
<BLOCK>line 1
line2</BLOCK>
<BLOCK>line 1
line2</BLOCK>
Just wanted to share ...
Markus
people can find it via google:
I have a data file that contains blocks of data, separated by empty
lines:
line1
line2
line1
line2
Now I want to read it on the command line, one block at a time. But
perl -pe '...' reads only single lines.
The answer is: Use -00
So, this:
perl -00 -ne 'chomp; print "<BLOCK>$_</BLOCK>\n"' data.txt
Prints
<BLOCK>line 1
line2</BLOCK>
<BLOCK>line 1
line2</BLOCK>
Just wanted to share ...
Markus