Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Elegant way to dereference an array or hash?by danb (Friar) |
on Nov 16, 2004 at 19:27 UTC ( [id://408219]=perlquestion: print w/replies, xml ) | Need Help?? |
danb has asked for the wisdom of the Perl Monks concerning the following question: Are there any elegant ways to dereference an array or hash besides @{} and %{}? In my opinion, the standard method gets ugly in cases like this:
I see the problem as the @ not being close enough to the variable that it is operating on. It's next to foo when it should be close to baz. Many people work around the problem at the expense of some elegance:
Here is a fictional alternative that requires the baz array ref to be an object instead of a primitive array:
Here is another fictional alternative that may conflict with existing valid syntax (and therefore would not be backwards compatible if implemented):
(As a side note, is Perl 6 going to be different in this regard?) -Dan
Back to
Seekers of Perl Wisdom
|
|