{ local $/ = ""; # Edit: added use of local for good practice while () { s/^##.*//s unless /^\w/m; print; } } __DATA__ ## Remove ## Keep this ## Remove ## Also keep that