Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I think that Version (2) and (1) do exactly the same thing.
Version 2 is easier to understand. And I think that it is as least as fast if not faster. If we are benchmarking things, then we need to to "apples to apples".
#!/usr/bin/perl -w use strict; use Data::Dumper; ## version 1.... my $num =0; my %h = map{$_, $num++}('A'..'Z','a'..'z'); print Dumper \%h; ## version 2... my %hash; foreach my $letter (('A'..'Z','a'..'z')) { $hash{$letter}++; } print Dumper \%hash; foreach (sort keys %h) { print "$_ OK\n" if $hash{$_}; }
$VAR1 = { 'S' => 18, 'a' => 26, 'T' => 19, 'N' => 13, 'K' => 10, 'd' => 29, 'Y' => 24, 'E' => 4, 'j' => 35, 'y' => 50, 'Z' => 25, 'u' => 46, 'k' => 36, 'g' => 32, 't' => 45, 'e' => 30, 'J' => 9, 'W' => 22, 'v' => 47, 's' => 44, 'B' => 1, 'H' => 7, 'c' => 28, 'q' => 42, 'b' => 27, 'D' => 3, 'I' => 8, 'G' => 6, 'z' => 51, 'U' => 20, 'w' => 48, 'F' => 5, 'r' => 43, 'x' => 49, 'V' => 21, 'Q' => 16, 'h' => 33, 'M' => 12, 'C' => 2, 'L' => 11, 'f' => 31, 'i' => 34, 'A' => 0, 'n' => 39, 'O' => 14, 'X' => 23, 'P' => 15, 'm' => 38, 'l' => 37, 'p' => 41, 'R' => 17, 'o' => 40 }; $VAR1 = { 'S' => 18, 'a' => 26, 'T' => 19, 'N' => 13, 'K' => 10, 'd' => 29, 'Y' => 24, 'E' => 4, 'j' => 35, 'y' => 50, 'Z' => 25, 'u' => 46, 'k' => 36, 'g' => 32, 't' => 45, 'e' => 30, 'J' => 9, 'W' => 22, 'v' => 47, 's' => 44, 'B' => 1, 'H' => 7, 'c' => 28, 'q' => 42, 'b' => 27, 'D' => 3, 'I' => 8, 'G' => 6, 'z' => 51, 'U' => 20, 'w' => 48, 'F' => 5, 'r' => 43, 'x' => 49, 'V' => 21, 'Q' => 16, 'h' => 33, 'M' => 12, 'C' => 2, 'L' => 11, 'f' => 31, 'i' => 34, 'A' => 0, 'n' => 39, 'O' => 14, 'X' => 23, 'P' => 15, 'm' => 38, 'l' => 37, 'p' => 41, 'R' => 17, 'o' => 40 }; A OK B OK C OK D OK E OK F OK G OK H OK I OK J OK K OK L OK M OK N OK O OK P OK Q OK R OK S OK T OK U OK V OK W OK X OK Y OK Z OK a OK b OK c OK d OK e OK f OK g OK h OK i OK j OK k OK l OK m OK n OK o OK p OK q OK r OK s OK t OK u OK v OK w OK x OK y OK z OK Process completed successfully

In reply to Re: Efficiency of map vs. more verbose basic/fundamental code by Marshall
in thread Efficiency of map vs. more verbose basic/fundamental code by marquezc329

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (7)
    As of 2014-07-11 21:09 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      When choosing user names for websites, I prefer to use:








      Results (235 votes), past polls