Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.

Freelancer

AdvertiseWithUs

Check overlaps with Perl

  • Public
By Jit 303 days ago
#!/usr/bin/perl use strict; use warnings; #For normal overlaps my ($lower, $upper) = (40, 100); for my $num (17,42,99,111) { my $is_between = (sort {$a <=> $b} $lower, $upper, $num)[1] == $num; printf "$num is%s between $lower and $upper\n", $is_between ? "" : " not"; } #For range to range overlaps #!/usr/bin/perl use strict; use warnings; use 5.010; my ($lower, $upper) = (40, 100); for my $range ( [10,17], [30,71], [42,99], [83,120], [101,111] ) { my $is_within = [(sort {$a <=> $b} $lower, $upper, @$range)[1,2]] ~~ $range; printf "[@$range] is%s within [$lower $upper]\n", $is_within ? "" : " not"; }