I didn't program for a long time (close to 10yrs), I still were sure that $#array is the last item, but I was too lazy to look up, how to note it when it is a $arrayref, so I just took 0..@$arrayref-1 what works same here and for at least where I stopped, it was same idiomatic. Every programmer in the world understand 0..length(array)-1 in a heartbeat, only Perl cracks will understand $[..$#array.
I wasn't aware that I could just $#array -= $n to make the array smaller. To be honest, I'm not sure whether I'd like it. It works only in so rare cases where we basical want to pop @array, $n and don't care about what were the last items. splice is a clear idiom that we intend to remove entries out of an array and then specify which. If the special case were more often, o.k., but how often do we even use splice? IMHO that is even rare, most of the time we pop, shift or slice with @array[4..7,11..13] and so on, so no need to trick us selfs just to trick us. Code should be easy.
Anyway, pretty to cool to have learned some new tricks in Perl :-)
Greetings,
Janek Schleicher
In reply to Re^3: removing duplicates from an array of hashes
by bigj
in thread removing duplicates from an array of hashes
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |