If all lines of a block of text contains leading space/s, I want to left justify by removing as many leading spaces as possible.
my $s = <<'EOS'; hello there test EOS my $m = 32000; # regex /^ {$m}/ blows up if $m > 32766 while ($s =~ /^( *)/mg) { $m = length($1) if length($1) < $m } $s =~ s/^ {$m}//mg if $m;
Improvements welcome.
In reply to Remove leading spaces (left justify) by eyepopslikeamosquito
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |