#!/usr/bin/perl -w use strict; my $file_contents; while( ){ next unless ( /^--/ || /^$/ ); $file_contents .= $_; } print $file_contents; __DATA__ --keep me delete me -- don't not throw this one out. -- delete every line that does NOT begin with two dashes... -- is the same as keep every line that begins with two dashes