So, maybe an explanation of what exactly $/ does would get me started.

From perldoc perlvar

     $/      The input record separator, newline by default.
             This influences Perl's idea of what a "line" is.
             Works like awk's RS variable, including treating
             empty lines as a terminator if set to the null
             string.  (An empty line cannot contain any spaces or
             tabs.)  You may set it to a multi-character string
             to match a multi-character terminator, or to "undef"
             to read through the end of file.  Setting it to
             "\n\n" means something slightly different than
             setting to "", if the file contains consecutive
             empty lines.  Setting to "" will treat two or more
             consecutive empty lines as a single empty line.
             Setting to "\n\n" will blindly assume that the next
             input character belongs to the next paragraph, even
             if it's a newline.  (Mnemonic: / delimits line
             boundaries when quoting poetry.)

                 local $/;           # enable "slurp" mode
                 local $_ = <FH>;    # whole file now here
                 s/\n \t+/ /g;

             Remember: the value of $/ is a string, not a regex.
             awk has to be better for something. :-)

             Setting $/ to a reference to an integer, scalar
             containing an integer, or scalar that's convertible
             to an integer will attempt to read records instead
             of lines, with the maximum record size being the
             referenced integer.  So this:

                 local $/ = \32768; # or \"32768", or \$var_containing_32768
                 open my $fh, $myfile or die $!;
                 local $_ = <$fh>;

             will read a record of no more than 32768 bytes from
             FILE.  If you're not reading from a record-oriented
             file (or your OS doesn't have record-oriented
             files), then you'll likely get a full chunk of data
             with every read.  If a record is larger than the
             record size you've set, you'll get the record back
             in pieces.

             On VMS, record reads are done with the equivalent of
             "sysread", so it's best not to mix record and non-
             record reads on the same file.  (This is unlikely to
             be a problem, because any file you'd want to read in
             record mode is probably unusable in line mode.)
             Non-VMS systems do normal I/O, so it's safe to mix
             record and non-record reads of a file.



In reply to Re: help substituting whitespaces? by Abstraction
in thread help substituting whitespaces? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.