Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

(dkubb) Re: (2) Better way?

by dkubb (Deacon)
on Feb 16, 2001 at 11:50 UTC ( [id://58811]=note: print w/replies, xml ) Need Help??


in reply to Re: Better way?
in thread Better way?

MeowChow, here's another version using a hash slice instead of a for loop to assign the contents of one hash to another:

my %old = ( 1 => a, 2 => b, 3 => c, 4 => d, 5 => f, ); my @keys = qw(4 5 6 7); #Keys to copy from the old to the new hash my %new; @new{ @keys } = @old{ @keys };

In this case, the difference between using a for loop and a hash slice means a slight edge in speed during benchmarking. However, the larger the data set the wider the gap becomes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-12-07 03:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (49 votes). Check out past polls.