in reply to On Removing Elements from Arrays

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")