Just another Perl shrine | |
PerlMonks |
Re^4: why avoid & on function callby LanX (Saint) |
on Dec 27, 2020 at 20:41 UTC ( [id://11125825]=note: print w/replies, xml ) | Need Help?? |
> 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
In Section
Seekers of Perl Wisdom
|
|