Using delete and exists on array elements is something you should discourage in the vast majority of cases. The greatest impact it will have is confusion. The most likely cases you will see of this use is by people who don't understand what they are doing.

When this was originally proposed, the majority of the Perl5 Porters were against it, many of them quite vehemently, including many of the porters that I most respect. The discussion of the issue was ended because Larry Wall said "Put it in. Blame me." (only slightly paraphrased). So I am obliging him on that second request. (:

So now you can effectively store in each element of an array not only "any scalar value" (including undef) but also the newly standardized "non-existant" "value" which cannot be stored in a scalar variable.

So if you want to make use of this new "meta value" and then you decide that you want to copy an array, you have to go to extreme lengths:

my @x; $x[6]= 1; print "\$x[1] exists? ", ( exists $x[1] ? "yes" : "no" ), $/; my @y= @x; print "\$y[1] exists? ", ( exists $y[1] ? "yes" : "no" ), $/; __END__ Produces: $x[1] exists? no $y[1] exists? yes

I would really like the use of exists and delete on arrays to require a pragma, like use existArray (no particularly good names came to mind).

But in the mean time, I'll "just say 'no'"!

        - tye (but my friends call me "Tye")

In reply to (tye)Re: On Removing Elements from Arrays by tye
in thread On Removing Elements from Arrays by footpad

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.