A few years back, I have adopted the following “pattern” for all except the most simple of my Perl scripts: (I don’t even remember where I saw it first, it certainly wasn’t my genuine idea.)
use strict;
...
sub main {
...
}
... possibly more subs ...
... at the end of the file:
#############
# Call main #
&main();
#############
Is there any benefit to this? I find the code a little cleaner, but otherwise I’m not sure this has any purpose other that to make the C programmer in me happy 🙂
Any insights from Perl experts and power users appreciated. (I am certainly neither)
It’s a known idiom to limit scope. This is discussed in https://stackoverflow.com/q/1183876#comment-1012787 ff. and http://use.perl.org/comments.pl?sid=43991&cid=70918 ff.