Dear Monks

I have some challenges with scoping.

Package SECANA::TimeString which is just a DateTime module wrapper In the package:

# 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 works via the Exporter
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
This does not work:
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
I get this warning:
This comes independently of using the exporter Name "SECANA::TimeString::FORMAT" used only once: \ possible typo at ./test-timestring.pl line 17.
any Idea what I'm doing wrong?

Thanks MortenB, Oslo Norway


In reply to perl our scoping from packages by netrom

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.