use Regexp::Common qw/comment/; local $/; $_ = ; s/$RE{comment}{C}\n*//gm; print; __DATA__ /* I have good commenting style */ i = 1; /* And I comment every line of code */ i++; /* Even if it's pointless */ j = i; j++;