in reply to [Answered!] Taking a subset of a hash
Does anyone know an elegant way to write this?
Perhaps?
my %small_hash; my @retain = grep{ defined $config{ $_ } && $config{ $_ } ## not false } @interesting_keys; @small_hash{ @retain } = @config{ @retain }; return \%small_hash;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Taking a subset of a hash
by Narveson (Chaplain) on Oct 30, 2010 at 13:28 UTC | |
by BrowserUk (Patriarch) on Oct 30, 2010 at 13:59 UTC |