#!perl use strict; my $str = '0000000NNNN00NNN0NNN0N0N0NN0N'; my @str = split '',$str; # input my @mask = map{ 'N' }(0..$#str); while (){ chomp; my (undef,$start,$end) = split "[,\t]",$_; for my $ix ($start..$end){ $mask[$ix-1] = ' '; } } # process my @output=(); for my $ix (0..$#str){ $output[$ix] = ($mask[$ix] eq 'N') ? 'N' : $str[$ix]; } # output print 'mask ',join '',@mask,"\n"; print 'string ',join '',@str,"\n"; print 'result ',join '',@output,"\n"; # intervals no,start,end __DATA__ 1,2,4 2,6,10 3,20,25 4,28,28