I don't know about the Y part of your quasi-
XY Problem, but the X part might be approached like this (among several possibilities):
perl -wMstrict -le
"my $lines = do {
local $/ = qq(\cD);
my $in = <STDIN>;
chomp $in;
$in
};
print $lines
"
qwert
asdf
zx^D
qwert
asdf
zx
Note that you still have to enter a newline after the ^D, and also, oddly, you can enter other characters between the ^D and the newline, but they will not be captured by the script.
C:\@Work\Perl\monks\zemane>perl -wMstrict -le
"my $lines = do {
local $/ = qq(\cD);
my $in = <STDIN>;
chomp $in;
$in
};
print $lines
"
the cow
jumped over
the moo^Dn whoops!
the cow
jumped over
the moo
Also note that this code captures the multi-line input as a single line, not as an array, but that's a detail, a mere detail!
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.