Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: iterations in a hash

by Loops (Curate)
on Aug 04, 2013 at 15:10 UTC ( [id://1047801]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %hash=(A=>4, B=>5, C=>10, D=>2, E=>9);
    my @zip = map { [ $_, $hash{$_} ] } sort keys %hash;
    ...
       my $f = shift @zip;
       print ("@$f * @$_ = ", $f->[1] * $_->[1], "\n") for (@zip);
    } while (@zip);
    
  2. or download this
    my %hash=(A=>4, B=>5, C=>10, D=>2, E=>9);
    my @zip = sort keys %hash;
    ...
           print "$f($v1) * $_($v2) = ", $v1 * $v2, "\n";
       }
    } while (@zip);
    
  3. or download this
    A(4) * B(5) = 20
    A(4) * C(10) = 40
    ...
    C(10) * D(2) = 20
    C(10) * E(9) = 90
    D(2) * E(9) = 18
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 10:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found