in reply to Deleting the first line of a file
If you don't want to mess around with the seeking and truncating, just open it twice:open(FOO, "+< $myfile") || die "Could not open $myfile $!\n"; @bar=<FOO>; shift(@bar); seek(FOO, 0, 0); truncate(FOO, tell); print FOO @bar; close(FOO);
open(FOO, "$myfile") || die "Could not open $myfile $!\n"; @bar=<FOO>; shift(@bar); close(FOO); open(FOO, ">$myfile") || die "Could not open $myfile $!\n"; print FOO @bar; close(FOO);
|
|---|