WOW! Many thanks, it works like a charm

Since perl it usually chokes (not an array ref on...) on object array references like so: foreach(@$obj->{array_ref}) I figured that it would also choke on $#{$obj->{array_ref}} by not recognizing the array ref in the inner reference. That's why I did'nt bother trying and following my instinct (which usually has worked in Perl!) went ahead on the use of $#{@{
But that looked pretty awkward so I went and searched a lot CPAN code to see if anyone else was using it, and well, you know the rest of the story :)

I guess I'll have to study a lot on Introspection and Globs to get the answer to that one, huh?

Update: Hmmm. After re-reading this, I think I have just answered myself: the same way that @{ "casts" to array is the same way $#{ "casts" to array also. Silly me! Thanks again for making me understand this!

In reply to Re^2: A question of perlish elegance on array loop by ait
in thread A question of perlish elegance on array loop by ait

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.