my $total_coverage = 0; #looping variable
my $interval = "/Users/logancurtis-whitchurch/Desktop/chrX_divisions/"
+."$region"."_$filter".".txt"; #specifiecs intervals by region and fil
+ter version
open (INTERVAL, "<$interval") or die "can't open interval file\n";
foreach ( <INTERVAL> ) {
my (undef, $start, $end) = split '\s+', $_;
my $subs_length = $end-$start;
my $included_length = substr( $cgs, $start, $subs_length );
my $coverage = $included_length =~ tr[0][];
$total_coverage = $total_coverage + $coverage;
}
print "$total_coverage\n";
Your approach uses an understanding of the language that I hope to attain some day, quite cool. Thank you! |