It's rather simple: split uses the pattern you supply as a separator. So it split the list into two items "" and "" separated by "201004061749". Then (as described in the split documentation), since you have parenthesis in your pattern, split inserts the captured groups into the result list. So it's returning ("", "2010", "04", "06", "17", "49", "").

I'm guessing you really wanted to use the match operator and assign the list of captured values to your list of variables.

UPDATE: I just tried it, and was mistaken, there's no "" at the end of the list that split returns:

[13:19:56] /DOS/c/Program Files/Bank of America/EFS $ perl -e '$_="201004061749";print "<",join(".",split/(\d\d\d\d)(\d\d) +(\d\d)(\d\d)(\d\d)/),">"' <.2010.04.06.17.49>

In reply to Re: I thought I understood split... by roboticus
in thread I thought I understood split... 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.