use strict; use warnings; open INFILE, '<', scalar <>; open OUTFILE, '>', scalar <>; print OUTFILE map{" \n\n $_ \n\n "} grep { not m/^#/ } ;