Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: how to loop through hash tables more efficiently

by tobyink (Canon)
on Sep 17, 2012 at 21:08 UTC ( [id://994107]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    foreach my $k1 (keys %$h1) {
        my @fields = split /,/, $h1->{$k1};
        ...
    }
    
  2. or download this
    while (my ($k1, $v1) = each %$h1) {
        my @fields = split /,/, $v1;
        ...
    }
    
  3. or download this
    use 5.010;
    use strict;
    ...
        { push @{ $tmp{$_} }, $k for split /,/, $v }
    for (values %tmp)
        { next if @$_ < 2; say join ',', @$_ }
    
  4. or download this
    say $_ for sort map { join ',', @$_ } grep { @$_ > 1 } values %tmp;
    

Log In?
Username:
Password:

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

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

    No recent polls found