my $count3="-1"; foreach my $lane (@array) { if ($lane eq "--\n"){$count3++;print "\t" x $count3 . "0\n";} else {print "\t" x $count3 . "$lane"} } #### 0 0.0175 0.0483 0.0507 "\t" 0 "\t" 0.0471 "\t" 0.0483 "\t\t" 0 "\t\t" 0.0287 "\t\t\t" 0