open( SEQ, "/Users/logancurtis-whitchurch/Dropbox/thesis_folder/consensus_files/mask_files/mask."."$population".".chr.23.txt" ) or die "can't open masked file\n"; my $bigScalar = ; close SEQ; open (INTERVAL, "<$filtered_sites") or die "can't open $filtered_sites"; my $lastEnd = 0; while( ) { my( $start, $end ) = split "\t", $_; ## change everything from the end of the last range ## to the start of this range to 'N' substr( $bigScalar, $lastEnd, $start ) =~ tr[\x00-\xff][N]; $lastEnd = $end; } close INTERVAL; ## change everything from the end of the last range to the end of string to 'N' substr( $bigScalar, $lastEnd, length( $bigScalar ) ) =~ tr[\x00-\xff][N]; ## do something with $bigScalar ...