The very difference is that in your approach the programmer has to create package Foo explicitly, while in my toy I wanted to let the user define globals using some "service" from a module.
So in what package are your non-global subroutines defined? :-) update: I mean; you're not defining all your code in the same package, since that would make vars::global unnessicary. But if you're using logical packages anyway, you can use those to export from.
This is probably where the "disadvantage" creeps in: the approach in vars::global is probably too easy...
Yeas... but my biggest gripe is that by constricting all globals to vars::global you can't structure your globals into logical packages. I mean, vars::global::query() isn't really as descriptive as MyDatabase::query() or CGI::query()

I must confess to using main:: as a global namespace sometimes, especially when I'm experimenting, but I try to move as much code as possible into logical classes/packages when the structure becomes clear.


In reply to Re^3: Global variables by Joost
in thread Global variables by polettix

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.