Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Re: Re: Need some help with a dodgy variable

by tachyon (Chancellor)
on Jul 31, 2001 at 17:06 UTC ( #101142=note: print w/ replies, xml ) Need Help??

in reply to Re: Re: Need some help with a dodgy variable
in thread Variable Scope

The only way to get the result you note is to call that_sub() before this_sub(). This prints "Hello Jeff" just fine

sub this_sub { $this_variable = "Jeff"; } sub that_sub { print "Hello "."$this_variable"; } this_sub(); that_sub(); # prints Hello Jeff

All I can presume is that your test case above is not the same as your real code as the test works exactly as expected. this_sub sets the global var $this_variable which is then available everwhere.




Comment on Re: Re: Re: Need some help with a dodgy variable
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://101142]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2015-08-01 02:08 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (285 votes), past polls