$var = "VARIABLE"; END {print "this is at the end:$var\n";} BEGIN {print "this is in the beginning:$var\n";} ##OUTPUT: $ perl script.pl this is the beginning: this is at the end:VARIABLE