By the way: I hate to assume that you may have mis-typed,
but since (as
turnstep wrote) $\ is so rarely used,
perhaps you meant $/? $/ is used much more often than $\,
because it's used when you want to alter the behavior of
the <> operator, which by default reads a file in
a line at a time. For example, say that you want to read
in the entire file in one slurp:
{
local $/ = undef;
$_ = <FH>;
}
The entire file is now in $_, which is nice.
Here's the entry from perlvar:
$/ The input record separator, newline by default.
Works like awk's RS variable, including treating
empty lines as delimiters if set to the null string.
(Note: An empty line cannot contain any spaces or
tabs.) You may set it to a multi-character string
to match a multi-character delimiter, or to undef to
read to end of file. Note that setting it to "\n\n"
means something slightly different than setting it
to "", if the file contains consecutive empty lines.
Setting it to "" will treat two or more consecutive
empty lines as a single empty line. Setting it to
"\n\n" will blindly assume that the next input
character belongs to the next paragraph, even if
it's a newline. (Mnemonic: / is used to delimit
line boundaries when quoting poetry.)
undef $/;
$_ = <FH>; # whole file now here
s/\n[ \t]+/ /g;
Remember: the value of $/ is a string, not a regexp.
AWK has to be better for something :-)
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.