Sorry, I got a bit tied up with something! Try something like this - your data is in an array but otherwise....
use strict;
use warnings;
my ($i, @array, $bin, $line);
my @input = (
"5893 5985 + LOC645399 645399",
"7223 7231 - LOC100131533 100131533",
"7630 9882 - LOC100131533 100131533",
"10142 11428 + LOC100132836 100132836",
"12197 13705 - LOC100132070 100132070",
"14248 15806 - LOC100132865 100132865",
"16830 17405 - LOC100132865 100132865",
"18735 19817 + LOC645399 645399",
"20802 23113 - LOC100132865 100132865"
);
for ($i = 5893; $i <=23113; $i++) {
$bin = $i += 7704;
push @array, $bin ;
}
foreach $line (@input) {
$line =~ m/\s*(\d+)\s*(\d+)/;
foreach my $bin (@array) {
if (($bin >= $1) && ($bin <= $2)) {
print "$1 $2\n";
last;
}
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|