Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^5: globally seen variable

by moritz (Cardinal)
on Sep 29, 2010 at 08:41 UTC ( #862562=note: print w/replies, xml ) Need Help??


in reply to Re^4: globally seen variable
in thread globally seen vairable

Contrary to the example you gave previously, you now seem to have the two snippets in question in different files. Which means that they don't share a lexical scope. So my explanation with lexical aliases doesn't apply in the new case.

A lesson you can learn from is that it's not efficient to ask very general questions first, if you really want to solve a specific problem; neither is asking a question that doesn't actually demonstrate the problem.

To answer your question, you need to either declare a lexical alias in each scope, to the same variable in the same package, or you need to qualify the namespace in one of the locations:

{ our $ERRORFILE = 'foo'; } { package RecordError; print $main::ERRORFILE, "\n"; }
Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://862562]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2018-07-21 23:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (450 votes). Check out past polls.

    Notices?