http://www.perlmonks.org?node_id=412878


in reply to newlines in regular expressions

None of the non-<>-print solutions I see here will cope with a single opening blank line since they all search for multiple \n characters. This does the trick using the /m modifier, which allows ^ to match the beginning of a line anywhere in your string:

perl -p0777e 's/^\n+//mg'