in reply to Sub routines not playing fair

They will only get activated if they get called somewhere. Really.

I should also note that putting named subs inside another sub doesn't make much sense in perl. The names will get installed as global names in the current package anyways (at compile time even). And you will get very strange effects as soon as closures start playing a role.

Executive summary: don't do that.

Replies are listed 'Best First'.
Re^2: Sub routines not playing fair
by pg (Canon) on Oct 24, 2004 at 01:04 UTC
    "And you will get very strange effects as soon as closures start playing a role."

    Here is thospel's strange effects ;-)

    do_this("abc\n"); do_this("123\n"); sub do_this { my $msg = shift; new_sub(); sub new_sub { print $msg; } }

    This prints:

    abc abc