Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Slicing and Destructing a Hash

by Enlil (Parson)
on Sep 02, 2005 at 03:32 UTC ( #488541=note: print w/ replies, xml ) Need Help??


in reply to Slicing and Destructing a Hash

Something like so?

use warnings; use strict; use Data::Dumper; my %hash = (a => 3, b=> 4, c =>1 ,d=>7); my @sel = qw(b c); my %nhash; @nhash{@sel} = delete @hash{@sel}; print Dumper \%hash; print Dumper \%nhash; __END__ $VAR1 = { 'a' => 3, 'd' => 7 }; $VAR1 = { 'c' => 1, 'b' => 4 };

-enlil


Comment on Re: Slicing and Destructing a Hash
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2015-07-29 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls