My Perl script outputs and logs many lines of text, and it does some cleanup and compresses some logs in an END
block.
The problem is when you do something like this on the command line:
perl myscript.pl | head -n 10
This causes the script to die as soon as it outputs 10 lines, so the END
block doesn't get executed and the logs don't get compressed. Is there a way to get around this and make sure the code in my END
block is still executed?