in reply to Is there a simple syntax to logically slice a hash?
You can take a functional approach and chain grep and map on a single line:
#! perl use strict; use warnings; use Data::Dump; my %h1 = (catastrophe => 1, cataclysm => 2, dogma => 3); my %h2 = map { $_ => $h1{$_} } grep { /^cat/ } keys %h1; dd %h2;
Output:
1:33 >perl 542_SoPW.pl ("catastrophe", 1, "cataclysm", 2) 1:37 >
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In Section
Seekers of Perl Wisdom