BhariD has asked for the wisdom of the Perl Monks concerning the following question:
I have to check whether a given number falls in the range. I have the following script: I have pasted an example here, I am reading the $start and $end number from another file..
use strict; use warnings; #start and end number from another file my $start = '20'; my $end = '100'; #reading another file, to retrieve info based on if the #$start and $end numbers above falls in the range #specified in a given line.. while (my $line = <DATA>){ chomp $line; my @cols = split(/\t/, $line); # the range from a different file $startPosition = $cols[1]; $endPosition = $cols[2]; #here how should I check if the $start and $end #in the range of $startPosition and $endPosition? { #if true print line print $line, "\n"; } }
<DATA> CP1006 100 200 CP1006 110 200 CP1006 40 100 SPS008 60 110
Thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: how to check if a number falls in a range?
by almut (Canon) on Mar 14, 2010 at 20:23 UTC | |
Re: how to check if a number falls in a range?
by Corion (Patriarch) on Mar 14, 2010 at 17:39 UTC | |
Re: how to check if a number falls in a range?
by toolic (Bishop) on Mar 14, 2010 at 17:49 UTC |
Back to
Seekers of Perl Wisdom