use strict; use warnings; my $string = "next line is spaces next line is tabs and now some newlines end"; $string =~ s/^\s*$/x/mg; print "$string\n";