#! Only need be 60 in this example but excess bytes don't effect the results. my $result = "\0" x 100; use constant LOW =>0; use constant HIGH =>1; for my $range (@ranges) { substr( $result, $range->[LOW], $range->[HIGH] - $range->[LOW] +1 ) = '1' x ($range->[HIGH] - $range->[LOW] +1 ) }