in reply to Hash/Array slice : how to exclude items?
Given:
my @unwanted = qw( schema log );
You can use:
my %unwanted = map { $_ => 1 } @unwanted; my @wanted = grep !$unwanted{ $_ }, keys %hash; my %subhash = %hash{ @wanted }; do_something( \%sub_hash );
Or:
my %subhash = %hash; delete @subhash{ @unwanted }; do_something( \%sub_hash );
Or:
delete local @hash{ @unwanted }; do_something( \%hash );
|
|---|