[Templates] keys.sort.grep.join

Paul LeoNerd Evans leonerd at leonerd.org.uk
Fri Nov 23 11:42:53 GMT 2007


On Wed, 21 Nov 2007 09:56:02 +0000 (GMT)
Anthony Gardner <cyclewood_ltd at yahoo.co.uk> wrote:

> $result = join( ',',  map{ $my_hash->{A_KEY}->{$_} }
>                                grep{ ! /some_string/ }
>                                sort keys %{$my_hash->{A_KEY}}
>                          );

Tiny nitpick - it's more efficient to grep out only the elements you
want, then sort those. No point sorting elements you're going to throw
away.

-- 
Paul "LeoNerd" Evans

leonerd at leonerd.org.uk
ICQ# 4135350       |  Registered Linux# 179460
http://www.leonerd.org.uk/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.template-toolkit.org/pipermail/templates/attachments/20071123/5b978c31/attachment.pgp 


More information about the templates mailing list