Just a wild guess, but one conceivable reason that $::version would not work is that it's being used before it has been assigned its value. After all - as you have use Arithmetic; - the code is in an implicit BEGIN {...} block. In other words, in case there's any initialisation in the module, that code might be executed before $::version is ready. For example, this would not work as one might expect at first:
#!/usr/bin/perl use strict; use warnings; $::version = shift @ARGV; BEGIN { # emulate "use Arithmetic;" package Arithmetic; sub load_config { my $config = "/usr/local/myapp/$::version/properties"; print "config: $config\n"; # ... } load_config(); }
In case you recognise any similarities to your scenario, you could try wrapping the assignment $::version = shift @ARGV; in a BEGIN block, which would make sure that things are being executed in the proper sequence.
In reply to Re^3: Using variables in top level script inside the perl modules
by almut
in thread Using variables in top level script inside the perl modules
by alih110
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |