Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: access to my variables from other subs

by Fastolfe (Vicar)
on Oct 24, 2000 at 18:57 UTC ( [id://38127]=note: print w/replies, xml ) Need Help??


in reply to access to my variables from other subs

Don't mean to point out the obvious, but just in case you aren't against re-coding slightly or have different reasons for trying to do this that the others might not notice, I want to at least point out the fact that this might be better done via arguments to c():
&a; &b; sub a { my $var = 1; &c($var); } sub b { my $var = 2; &c($var); } sub c { my $var = shift; print "var=$var\n"; }
Generally you either want to scope something globally (or at least within the block that these functions will operate), or pass things as arguments and return values between your functions. Sorry if you're already aware of this and have other needs for using local/my variables in a pseudo-global capacity. Just wanted to get this out there.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-24 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found