Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: compare third column of one file with the first column of another

by pme (Prior)
on May 06, 2016 at 09:20 UTC ( #1162338=note: print w/replies, xml ) Need Help??


in reply to compare third column of one file with the first column of another

Hi AM,

this little piece of code might help.

use strict; use warnings; open my $m, '<', 'mapped.txt' or die 'Cannot open mapped.txt'; while (<$m>) { chomp; my @l = split /\|/; open my $p, '<', 'ptt.txt' or die 'Cannot open ptt.txt'; while (<$p>) { next if /^Location/; chomp; my ($range) = split; my ($fm, $to) = split(/\.\./, $range); if ($l[1] >= $fm and $l[1] <= $to) { # here you can set which +column is used to compare print "$l[1] - $_\n"; } } close $p; } close $m;
  • Comment on Re: compare third column of one file with the first column of another
  • Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (12)
As of 2019-11-15 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (83 votes). Check out past polls.

    Notices?