in reply to Remove leading spaces (left justify)

this is hardly a regex problem..and in fact quite slow and resource hungry as you're looking lines ahead when there's no need. also it's quite difficult to work into such hard working regex any additional formatting of the text. a more extensible code, even though more long winded:
$par_indent = 0; # or +ve for first line indenting $line_indent = 5; # char pos baseline. +ve for hang indent $line = <>; ($spaces, $first_line) = $line =~ m/^( *)([^ ].+)/; $chop_chars = length $spaces; print ' ' x $par_indent . $first_line . "\n"; while ($line = <>) { print ' ' x $line_indent . substr $line,$chop_chars }