in reply to Re: how to loop through hash tables more efficiently
in thread updated_again: how to loop through hash tables more efficiently

really want to try out this code, but my work only have perl 5.8.8, doesn't have v5.10.0 yet, :( Thanks though, any other more efficiently traditional way to do it?
  • Comment on Re^2: how to loop through hash tables more efficiently

Replies are listed 'Best First'.
Re^3: how to loop through hash tables more efficiently
by Kenosis (Priest) on Sep 17, 2012 at 23:33 UTC

    Ah! Then the following should work:

    use strict; use warnings; use File::Slurp qw/read_file/; my ( $hash1, $hash2 ) = @ARGV or die $!; my %hash1 = map { /(.+?),(.+)/; $1 => $2 } grep /.,./, read_file $hash +1; my %hash2 = map { /(.+?),(.+)/; $1 => $2 } grep /.,./, read_file $hash +2; for my $key2 ( sort keys %hash2 ) { for my $key1 ( sort keys %hash1 ) { print "$key2\t$hash2{$key2}\t$key1\n" if $hash1{$key1} =~ /\b$ +hash2{$key2}\b/; } }