Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Threading two text files

by LanX (Saint)
on May 15, 2013 at 10:43 UTC ( [id://1033656]=note: print w/replies, xml ) Need Help??


in reply to Re: Threading two text files
in thread Threading two text files

> if speed matters consider reading both files first, if you put the data of the second into a hash you can check much faster.

like this

use strict; use warnings; use Data::Dump qw/pp/; open my $qqq,"<","qqq.txt" or die "Open qqq failed $!"; open my $exp,"<","exp.txt" or die "Open exp failed $!"; my @exp = <$exp>; chomp @exp; my %qqq; while (<$qqq>) { my ($value,$key) = split /\s+/; push @{$qqq{$key}},$value; } #pp \%qqq,\@exp; print "$_: @{$qqq{$_}}\n" for @exp;

out

a: 1 11 c: 333

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found