Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Find overlap

by Anonymous Monk
on Oct 14, 2012 at 02:47 UTC ( #998906=note: print w/replies, xml ) Need Help??


in reply to Re^2: Find overlap
in thread Find overlap

hi,

i'm not sure if i get the problem right but this script will find the min of all values in column 2 of all given files and the max of all values in column 3.

you just call it with the file names as arguments.

#!/usr/bin/perl -w use strict; my $min = undef; my $max = undef; foreach (@ARGV) { open(F, "< $_"); while(my $line = <F>) { chop($line); $line =~ s/[\ \t]+/:/g; my @p = split(/:/,$line); if(!defined($min)) { $min = $p[1]; } if(!defined($max)) { $max = $p[2]; } if($p[1] < $min) { $min = $p[1]; } if($p[2] > $max) { $max = $p[2]; } } close(F); } print "$min $max\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998906]
help
Chatterbox?
[marto]: LanX I'd rather commit sudoku :P
[marto]: trench humour folks, feeling rough.
[marto]: there is never a night when they sleep all the way through, but last night was something else
[marto]: gave in at 3:45 ish and let Charlie watch videos about spitfires, the battle of Britain. He's plane crazy
[1nickt]: marto soothing!
[marto]: Hiromi makes an appearance, let's hope Jools doesn't ruin it by joining in on the old Joanna
[1nickt]: karlgoethebier What is the issue with the semic-colon after the ellipsis? It's documented as proper syntax ...;
[karlgoethebier]: Crazy? What should i say? Son just started his third studies. Next week i have a session with my therapist ;-)
[marto]: and just as I type that, the boys begin playing the piano, the price I pay for using cockney slang :P

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2017-11-18 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (277 votes). Check out past polls.

    Notices?