First, Randal may not have written that line, the primary author on that book is Joeseph Hall.
perl -pe 's/\n/" " . <>/e' data
This is a command line, obviously, and if you read perlrun, you will read that -p will make the assumption that there is a while() loop around your code. So, this would look similar to the following, to Perl:
while (<>) {
s/\n/" " . <>/e;
}
As stated in other responses the /e allows you to be able to evaluate things on the right side of an s///.
2: if data is a filehande and this is a one-liner, how does data get input from a file with "\n"=separated values?
It isn't a filehandle, it is a file name. It get's the the data with \n seperated values because that is what the lines of the file are seperated with. This is not different that opening a file and itterating over it from within a script.
Cheers,
KM
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.