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

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.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://101142]
help
Chatterbox?
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
Sections?
Information?
Find Nodes?
Leftovers?
    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