Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

My dear monks

I'm really busting my brains over the following problem:

I've got a script with several modules, including one that reads in data from a configuration file. The module then stores the retrieved data in global variables, e.g. one that is declared with 'our $dataDirectory'. My log module needs to retrieve a path where to store its log file in, which is also retrieved by the Config.pm module. Here is the code:

package Logalizer::Log4Logalizer; use strict; use warnings; no warnings qw/ uninitialized /; use Carp; use Fcntl qw/ :DEFAULT :flock /; use Logalizer::Config; BEGIN { use Exporter(); our ($VERSION, @ISA, @EXPORT); $VERSION = 1.00; @ISA = qw/ Exporter /; @EXPORT = qw/ $verboseLevel &init &log /; } our $verboseLevel = 0; our $logName = "$Logalizer::Config::logDirectory/logalizer.log"; our $LOG = \*LOG; sub init { unless (-d $Logalizer::Config::logDirectory) { mkdir $Logalizer::Config::logDirectory, 0777 or croak "Can't mkdir $Logalizer::Config::logDirectory", ": $!"; } sysopen ($LOG, $logName, O_WRONLY | O_CREAT) or croak "Can't open $logName: $!"; }

...

I monitor $Logalizer::Config::logDirectory with carp()s and I get the correct path, let's say '/path/to/logfile'. I also monitor $logName, what I get, however, is '/logalizer.log', i.e. $Logalizer::Config::logDirectory doesn't seem to be interpolated in the above assignment. What's even more amazing is that the very same kind of assignment works in all the other modules. It's probably something obvious but I'm really at a loss here. Does anybody know what's going wrong and what I can do about it?

Any help will be greatly appreciated.

SveTho

In reply to Problems accessing fully qualified var from another module by svetho

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-19 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found