http://www.perlmonks.org?node_id=11125825


in reply to Re^3: why avoid & on function call
in thread why avoid & on function call

> Usually I add an explicit exit statement to the end of the main part of the code before the subroutines so it is obvious where the main block ends.

exit doesn't end scope.

If you have variables declared in your main part, they could accidentally leak as closures into the subs.

Using sub main { BLOCK } is one way to limit the scope.

I personally rather use a naked { BLOCK }

Like this the distinction to intentionally file-scoped variables outside this main BLOCK becomes obvious.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery