# Assume that the header is all the first block of commented # lines and that the first non-comment line ends the # header block while () { last unless is_comment($filetype, $_); } # Print new header to new file print NEWFILE new_header($filetype); # Print the rest of the file while () { print NEWFILE $_; }