my @counts = map { length } $string =~ /1(0*)/g; #### my @counts = map { length } $string =~ /1(?=(.*))/g;