"Is pseudo-hashes usefull ?" - You are certainly not the first person to ask that question :-)

I don't remember the exact reason why that feature was introduced. However, some of the pro opinions was:

IIRC, it was once a consistency problem between pseudo-hashes and arrays that led to the delete and exists functions being able to take array elements as well: @a = (1,2,3); delete $a[1] Now, this "little" feature introduces something interesting. We can "delete" an array element - but what does that mean ?
@a = (1,2,3); delete $a[1]; print "($_)\n" for @a;
This would produce the following:
(1) () (3)
Aha! So delete $a[1] must be the same as $a[1] = undef then ? Let's check that statement:
@a = (1,2,3); delete $a[1]; print "I'm ", exists $a[1] ? "here" : "gone"; @b = (1,2,3); $b[1] = undef; print "I'm ", exists $b[1] ? "here" : "gone";
And indeed, this invalidates my previous statement. For the output is:
I'm gone I'm here
So delete $a[1] is not the same as $a[1] = undef. Hm, isn't that strange ? Well, the story is this, when we use undef we set the variable to the special value undef. When we use delete it does not set our variable to the special value undef, but to the special special value called uninitialized. Uninitialized means that the variable has not been set at all.

This may seem strange but then again, pseudo-hashes and delete/exists on arrays is an experimental feature. (delete and exists on arrays was added in 5.6 IIRC).

If you ask me it is a good reason pseudo-hashes is experimental, if you are not interested in my opinion, then maybe the opinion of our current pumpkin for the development track of perl (5.7) might interest you :-)

Autark.


In reply to Re: Are pseudo-hashes worth the effort? by autark
in thread Are pseudo-hashes worth the effort? by Ovid

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.