Perl-Sensitive Sunglasses | |
PerlMonks |
Re^3: Perl Idioms Explained (explained)by Aristotle (Chancellor) |
on Aug 06, 2003 at 14:47 UTC ( [id://281421]=note: print w/replies, xml ) | Need Help?? |
Yep. As I said, it does not iterate on the Perl side. The pertinent nodes in optree are only ever seen once, and the loop is implicit in the execution of that single op. With all other approaches, the pertinent ops have to be dispatched and executed as many times as there are items in the list. In fact, the keys %{{map{$_=>1}@list}} approach needs to first iterate over all elements of @list for the map, building a list as it goes, then build another list for keys. In contrast, the @uniq = grep ! $seen{$_}++, @list; approach only builds a list once, while iterating over the elements of @list. And of course as already explained, undef @seen{@list}; @uniq = keys %seen; just builds a single list - without iterating at all. Makeshifts last the longest.
In Section
Meditations
|
|