in reply to Re: removing duplicates from an array of hashes
in thread removing duplicates from an array of hashes
Just a matter of idle curiosity... I notice you use @$ref-1 instead of $#$ref for obtaining the max array index. Why do you prefer this? If $[ were ever changed (but don't do that!), @$ref-1 would yield an incorrect value for max index. (Although I suppose that one could argue that to be $[-safe, one ought always to iterate over $[ .. $#array rather than 0 .. $#array to safely visit the entire range of @array indices.)
Also, in your second code example
splice @$ref,-$removed;
might be written as the (presumably) marginally faster
$#$ref -= $removed;
Update: I should make it clear that this post was prompted mainly by the non-idiomatic nature of the @$ref-1 expression. Any "lack-of-safety" issue is only a kind of cayenne pepper icing on the cake.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: removing duplicates from an array of hashes
by bigj (Monk) on Apr 18, 2014 at 14:23 UTC |