in reply to sub running on use statement
Your story isn't consistent. For a start use statements are executed during the compilation phase before any "normal" code is run so the output you suggest you see is not what I'd expect to see. Indeed, when I run the following code:
####### ScrewyModule.pm package ScrewyModule; use strict; use warnings; ScrewySubRoutine(); sub ScrewySubRoutine { print "running the sub\n"; } return 1; ####### noname.pl #!C:\Perl\bin use diagnostics; use strict; print "before use\n"; use ScrewyModule; print "after use\n";
I get:
running the sub before use after use
as expected.
Note though that I have an explicit call to ScrewySubRoutine in the module. If I omit that line then ScrewySubRoutine does not get called. I suspect that you have a call to ScrewySubRoutine in your module code outside any sub. Maybe you should run your code through PerlTidy to make sure the indentation is correct then go looking for unexpected code?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sub running on use statement
by Anonymous Monk on Dec 02, 2014 at 17:05 UTC |