#..................."~/test/DataBank.pm" package DataBank; + our @EXPORT_OK = qw( set_webpath get_scanpath get_findpath); my %webpaths = ( mypath => "", scanpath => "~/WebTabs/auto/htmlscan.0", findpath => "~/WebTabs/auto/htmlfilter.0" ); sub get_scanpath {return ($webpaths{"mypath"} || $webpaths{"scanpath"} +);} sub get_findpath {return ($webpaths{"mypath"} || $webpaths{"findpath"} +);} sub set_webpath { my $pathme = shift; unless (-f $pathme){$pathme = "";} $pathme ||= get_scanpath(); $webpaths{"mypath"} = $pathme; } #..................."~/test/Scanner.pm" package Scanner; ; our @EXPORT_OK = qw( postscan); use Importer 'SpecsGet' => qw( pathout ); sub webget {.........} # download heaps sub postscan { my $pathx = pathout(); print "\n$pathx\n\n"; } #..................."~/test/SpecsGet.pm" package SpecsGet; our @EXPORT_OK = qw( pathout); + use Importer 'DataBank' => qw( get_scanpath get_findpath ); sub pathout {return get_scanpath();} #..................."~/test/testme.pl" use Importer 'DataBank' => qw (set_webpath); use Importer 'Scanner' =>qw (postscan); use Cwd qw(getcwd cwd); set_webpath (getcwd()."/xxx"); #........................................# hours later postscan();

Given the 4 files above suitably 'stricted' etc & closed off properly:

#> perl testme.pl          ==>  "~/xxx"   ... (as expected)

Seems to function perfectly well, deploying DataBank.pm as a central store for 'modularised' semi-static specifications whose values may occasionally get changed by yet other modules. The problem I am having is not understanding exactly why it works so I can rely on it?

There are myriad net explanations of the seldom used "local", "our", & "package" scopings but very little on this "file" scoping that I (and maybe others) use extensively. If the "file"-scoped lexicals of DataBank.pm are forced to stay in scope throughout, what is doing the forcing with respect to scoping rules?


In reply to modular file scoping by Pstack

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.