Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Hash/Array slice : how to exclude items?

by ikegami (Patriarch)
on Jan 24, 2023 at 21:05 UTC ( [id://11149846]=note: print w/replies, xml ) Need Help??


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 );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11149846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found