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

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?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2018-10-18 11:04 GMT
Find Nodes?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...

    Results (101 votes). Check out past polls.