I always use strictures (use strict; use warnings;), partly because I also have a strong C++ background, but mostly because strictures catch a lot of silly errors. To help with that I often start large scripts with:
use strict; use warnings; run() sub run { ... }
and put all the variables that would go in a C/C++ main into run. Note that the default package is ::main so it's best to avoid that for a sub name to avoid possible confusion. Note too that Perl doesn't need subs declared before they are used (unless you use prototypes, but don't do that) so the run sub can be given later in the file than where it is first used. That seems more natural to me - the overview at the top with more detail as you read through the script.
Oh, and really, don't use prototypes. With a C++ background you will want to, but they are not what you think and will cause grief.
In reply to Re: does perl have a concept of "int main()"? (variable scoping question)
by GrandFather
in thread does perl have a concept of "int main()"? (variable scoping question)
by Special_K
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |