Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: scoping across parent/child relationship

by rchiav (Deacon)
on Aug 30, 2001 at 21:17 UTC ( [id://109136]=note: print w/replies, xml ) Need Help??


in reply to scoping across parent/child relationship

my ( $foo, %bar, $bax ); is scoped within the else. It doesn't look like Initialize_child exists within that scope. I think there are two options, of which I think only one would be recomended.

1) pass the variables to the sub (recomended)
2) create the sub within the else block (not recomended).

Just to further explain, here's some example code that will give you the same results.

# $foo and $bar are not accessable outside of this scope { my ($foo, $bar) = qw(Hello world); DoSomething(); } # this is outside of the above scope so it can not access $foo and $ba +r sub DoSomething { print "$foo $bar\n"; }
Or if it existed inside the scope (not recomended, just for demonstrative purposes)
# $foo and $bar are not accessable outside of this scope { my ($foo, $bar) = qw(Hello world); DoSomething(); # this is inside the scope so it can access $foo and $bar sub DoSomething { print "$foo $bar\n"; } }
Hope this helps
Rich

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 03:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found