in reply to passing a variable from one subroutine to another

First let me say that this advice comes from a neophyte, but I believe that in Chapter 8 of the Llama ...looks... yeah, on page 98 if you have it, you can make a variable available to any subs called from a sub by declaring it with local instead of my. So If you call the second sub from the first and declare with local, you should be able to share the value without going global.
hth
jg
_____________________________________________________
Ain't no time to hate! Barely time to wait! ~RH

Replies are listed 'Best First'.
Re: Re: passing a variable from one subroutine to another
by chromatic (Archbishop) on Oct 05, 2001 at 21:29 UTC
    It's still "global", or more accurately, "a fine upstanding resident of the symbol table". local doesn't work on lexical (declared with my) variables.

    local simply hides away the existing value for the duration of the lexical scope. It's still accessable through the symbol table (as a global), but within the scope, including in any subroutines called from the scope, it has a temporarily new value. For more practical information, scope out Seven useful uses of local by a local octopus enthusiast.

    There, that ought to protect you from merlyn!

      I really appreciate the links here, in following them I also found What's the difference between dynamic and lexical (static) scoping? Between local() and my()? to be very helpful.

      In reading the aforementioned passage in Llama (p98) again, it seems to me that adherance to the strict pragma is more of a PM thing. I get the feeling that, since merlyn addresses it briefly at Chapter 8 of Llama 2nd ed., the message of the Llama is that it is more efficacious not to worry about strict when beginning to learn perl. Comments? Trout slaps from Camel ot?
      TIA
      jg
      _____________________________________________________
      Ain't no time to hate! Barely time to wait! ~RH