netrom has asked for the wisdom of the Perl Monks concerning the following question:
I have some challenges with scoping.
Package SECANA::TimeString which is just a DateTime module wrapper In the package:
This works via the Exporter# default exported our @EXPORT_OK = qw( stringformat new_from_db new_from_string from_string epoch_dt now $TIMEZONE $FORMAT $LOCALE ); # default format scope as $SECANA::TimeString::FORMAT our $FORMAT = '%Y%m%d%H%M%S' if(! defined $FORMAT);
This does not work:use lib $ENV{'SECANAROOT'}."/lib"; use SECANA::TimeString qw($FORMAT); $FORMAT = '%a %Y-%m-%d %H:%M:%S %z'; print SECANA::TimeString::now().'\n'; Wed 2008-09-10 10:20:10 +0200
I get this warning:use lib $ENV{'SECANAROOT'}."/lib"; use SECANA::TimeString; $SECANA::TimeString::FORMAT = '%a %Y-%m-%d %H:%M:%S %z'; print SECANA::TimeString::now().'\n'; 20080910102010
any Idea what I'm doing wrong?This comes independently of using the exporter Name "SECANA::TimeString::FORMAT" used only once: \ possible typo at ./test-timestring.pl line 17.
Thanks MortenB, Oslo Norway
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: perl our scoping from packages
by ikegami (Patriarch) on Sep 10, 2008 at 09:38 UTC | |
|
Re: perl our scoping from packages
by netrom (Acolyte) on Sep 10, 2008 at 09:32 UTC |