in reply to deleting first line of a file using in-place editing

The -p option causes printing to occur via an assumed continue block. continue blocks execute even if you short circuit the assumed loop with next, so it becomes somewhat of a contortion skipping the first line while using the -p option. One way to do it (using the -p option) would be to read the first line in a BEGIN{} block and do nothing with it, but that's silly because there's a better solution. If you really don't want to print one (or maybe several) of the lines, retake control over print by using the -n option instead of -p.

perl -ni.bak -e "print if $line++;"

The preceeding snippet does an inline edit where the first line is not echoed back out to the output file again, but all subsequent lines are.


Dave