The first argument to split is a regex unless you want paragraph mode (and you don't)

That isn't what is happening here, this is a different special case documented in `perldoc -f split`:

As another special case, "split" emulates the default beha +vior of the command line tool awk when the PATTERN is either omitt +ed or a string composed of a single space character (such as ' ' o +r "\x20", but not e.g. "/ /"). In this case, any leading whi +tespace in EXPR is removed before splitting occurs, and the PATTER +N is instead treated as if it were "/\s+/"; in particular, this + means that any contiguous whitespace (not just a single space ch +aracter) is used as a separator. However, this special treatment ca +n be avoided by specifying the pattern "/ /" instead of the str +ing " ", thereby allowing only a single space character to be a sep +arator. In earlier Perls this special case was restricted to the u +se of a plain " " as the pattern argument to split; in Perl 5.18.0 + and later this special case is triggered by any expression whi +ch evaluates to the simple string " ". If omitted, PATTERN defaults to a single space, " ", trigg +ering the previously described awk emulation.

The references to awk are probably not very helpful these days, and probably discourage people from reading the rest and using this useful construct.


In reply to Re^2: Perl parse text file using hash by hv
in thread Perl parse text file using hash 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.