Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1008335]
[Corion]: Well, no computer will start up without the blood sacrifice being made!
[Corion]: I used to cut me on PC cases, but they've gotten better or I don't let blood that easy anymore ;)
[Corion]: You say the girls may strip with your permission, You draw the line dividing art from sin :-D

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2017-01-16 19:42 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.