You've already got some good responses, I just wanted to clarify terminology.

I need to differentiate an empty array from an uninitialized one.

There is no difference, an uninitialized array is empty. There is a difference between an empty array and an array of one or more undef values, but:

my $str_two =  ".5,,0,1," ; ... for $str_two the undefined element is skipped

As already pointed out by jwkrahn, in this case, the elements returned by split will not be undefined (undef), instead they will be empty strings. Although both are evaluated as "false" by perl (Truth and Falsehood), and undef evaluates to an empty string, it will normally warn when being evaluated as a string, and also testing with defined will show the difference between the two.

the resulting array is empty (or may I say "undefined")

I would recommend not calling an empty array "undefined", because that term is usually reserved for undef, which only applies to scalars like the elements of an array - but an empty array doesn't have any!

Is there a proper way to work around this problem with Perl 5?

In your last post from over a year ago, you asked about how to handle CSV data, and I recommended Text::CSV. Let me repeat that recommendation again, since it will properly distinguish between the cases of "" vs. ",,,,", and in the latter case it can even return an array of undef values, if you enable its blank_is_undef option (there is even empty_is_undef).

Update 2019-08-17: Updated the link to "Truth and Falsehood".


In reply to Re: How to differentiate an empty array from an unitialized one? by haukex
in thread How to differentiate an empty array from an unitialized one? by iatros

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.