Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: How to access outside variable

by biohisham (Priest)
on Jan 21, 2011 at 10:45 UTC ( #883504=note: print w/replies, xml ) Need Help??

in reply to How to access outside variable

Since $a is defined in the same package - main - what happens is that the value of $a gets merely overwritten, variables in the same package are global to that package scope,
#!/usr/local/bin/perl print __PACKAGE__ ; print "\n"; $a=10; { $a=11; print $a,"\n"; print __PACKAGE__ ; }
look up __PACKAGE__ in perlmod and perldata, coping with scoping can be a good read as well..

Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://883504]
[james28909]: but then you have the others as well
[Lady_Aleena]: Renaming things like get_THAC0 to just THAC0 was easy. These are harder.
[james28909]: consolidate the three subs into one
[Lady_Aleena]: Um, what?
[james28909]: check is is data or hash or array and do tasks then return needed data
[Lady_Aleena]: james28909, you might want to look at the other two on my scratchpad.
[james28909]: after you send to a sub, you can check if it is array or ref ect with ref

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-05-24 04:50 GMT
Find Nodes?
    Voting Booth?