in reply to Re: My globals are visable; but undef'ed
in thread My globals are visable; but undef'ed

Actually you probably shouldn't use our, see Why is 'our' good? for my explanation of why I don't like it when you're sharing data between modules.
  • Comment on Re^2: My globals are visable; but undef'ed

Replies are listed 'Best First'.
Re^3: My globals are visable; but undef'ed
by Joost (Canon) on Jul 31, 2008 at 20:05 UTC
    Well, there are enough cases where package variables are the only thing that works (mostly cases where perl insists on making package vars special). But your complaint isn't about that, exactly. Me, I just use our as a neater replacement for vars (IOW, I practically always just use our at the top of the script - and I prefer it over vars for that just because it looks better).

      I grant that it looks prettier, but if you're going to be sharing variables between scripts, it is distinctly worse.

      Within a script it doesn't matter which you use, but it is probably better to use my instead.

        I don't want this to turn into a long discussion, and I agree that using globals/package vars for sharing data is usually not a good idea (though it does work very well for most situations where you'd otherwise use "singletons" - especially when you can Export the variables). But I don't see what lexicals have to do with the post you referenced above.