Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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

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 wandering the Monastery: (5)
As of 2016-06-29 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (368 votes). Check out past polls.