How do I delete the 1st line on a file using perl?

tim85a

New member
Hi, I want to delete the first line of a file using perl. In my code, I have the file open and line saved as $line. But how can I delete $line from the file?
 
You need to open the file, read the entire file, and print out all EXCEPT the first line to the desired output file.

open INFILE, '<infile';
open OUTFILE, '>outfile';
<INFILE>; #discards first line
print OUTFILE $_ while (<INFILE>);
close OUTFILE;
close INFILE;
 
Back
Top