You have a seperator sequence so there must be something to the left of it - even if it is very short :). NOte that there doesn't have to be anything after. Consider:

use warnings; use strict; my $test =",124,456,7890"; print "Test string: >$test<\n"; my @matches = split m/(,)/, $test; print "Item $_ is >$matches[$_]<\n" for 0..$#matches;

Prints:

Test string: >,124,456,7890< Item 0 is >< Item 1 is >,< Item 2 is >124< Item 3 is >,< Item 4 is >456< Item 5 is >,< Item 6 is >7890<

DWIM is Perl's answer to Gödel

In reply to Re: I'm splitting a scalar and putting the results in an array. Why is the first element empty? by GrandFather
in thread I'm splitting a scalar and putting the results in an array. Why is the first element empty? by meanroy

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.