# and now using \s & /g # output smells bad print "and now using \\s only, with /g modifier\n"; my $count_s = 0; my $linecount_s = 0; for my $var(@var) { $linecount_s = scalar ( $var =~ s/\s/_/g ); print "\$linecount_s: $linecount_s, \$var after substitution: $var\n"; $count_s += $linecount_s; } print "\$count_s: $count_s \n\n";