in reply to sub running on use statement

Another possibility is that ScrewyModule.pm has a sub import() that calls other subs:
package ScrewyModule; sub import{ test(); } sub test{ print "in ScrewyModule.pm\n"; } 1;
In this case test() gets called (via import) when the module is "use"d.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

Replies are listed 'Best First'.
Re^2: sub running on use statement
by Anonymous Monk on Dec 02, 2014 at 17:21 UTC
    Yes, that's what I have in the module. Quite a few, actually.

    The sub-routine that I noticed this printing on is recursive, calling itself to fill an array with all the files in a directory tree. When that recursive subroutine was called from another module, it printed when I didn't expect it.

    One of the scalars passed by reference to that recursive subroutine is the parent directory to search. I'd inserted a print statement just after the references were taken from "$_" to confirm that the parent directory was correct.