in reply to
sorting type question- space problems
If you choose a solution that needs to tidy up (delete files, etc) after it finishes, or dies, then an END might be useful.
BEGIN, UNITCHECK, CHECK, INIT and END
An END code block is executed as late as possible, that is, after perl has finished running the program and just before the interpreter is being exited, even if it is exiting as a result of a die() function. (But not if it's morphing into another program via exec, or being blown out of the water by a signal--you have to trap that yourself (if you can).) You may have multiple END blocks within a file--they will execute in reverse order of definition; that is: last in, first out (LIFO). END blocks are not executed when you run perl with the -c switch, or if compilation fails.