The stupid question is the question not asked | |
PerlMonks |
Explaining @{ [ %hash ] }by jarich (Curate) |
on Sep 04, 2003 at 03:55 UTC ( [id://288787]=note: print w/replies, xml ) | Need Help?? |
What antirice has done here is to take a copy of the hash as a list. After this, interating over the copy means that every second delete attempts to delete a key that never existed in the hash and fails quietly while all the others succeed. No doubt you're confused by the bit. Enclosing something in square brackets in Perl takes it in list context. It also generates an array reference to that. So %hash here is copied into an annoymous array. This is then deferenced by the @{}s because foreach expects a list, not a reference. Does this help? All the best, jarich
In Section
Seekers of Perl Wisdom
|
|