Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 cooling their heels in the Monastery: (12)
As of 2014-08-20 17:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (120 votes), past polls