Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: better array to hash conversion

by tobyink (Abbot)
on Dec 11, 2012 at 16:24 UTC ( #1008335=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub variation3ep {
      my $idx = -1;
      my %hash = map(($_ => ++$idx), @array);
    }
    
  2. or download this
    #!/usr/bin/env perl
    use strict;
    ...
                Rate variation5 variation4
    variation5 740/s         --        -4%
    variation4 773/s         5%         --
    
  3. or download this
    sub variation6 {
        my $idx = -1;
        my %hash; $hash{ $_ } = ++$idx for @array;
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-07-03 20:28 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 (56 votes), past polls