http://www.perlmonks.org?node_id=678170


in reply to Re: Global destruction feature / bug ?
in thread Global destruction feature / bug ?

our doesn't differ significantly from use vars except that the syntax is nicer and the name is only available in the local scope even though the data is global to the namespace. I think it's well documented that our $bar doesn't go out of scope until global destruction.

I actually think the behavior of the parent program is exactly what you should expect if you read our and my carefully.

Please don't be down on our. It's 5.8 chic. :(

-Paul

  • Comment on Re^2: Global destruction feature / bug ?

Replies are listed 'Best First'.
Re^3: Global destruction feature / bug ?
by Corion (Patriarch) on Apr 03, 2008 at 14:24 UTC

    It's mostly because of that why I dislike use of our - it establishes a global variable except that I cannot get at it or change it from the outside. And in most cases I've encountered, there always comes a moment where I want/need to change a global variable. For example to add or change some configuration, or change the quote indicator from " to ' or `. And our prevents me from doing that while adding no benefit...

      You sure about that? That's really not the way I'm seeing it work. It's just like use vars, but shorter and only initially available where you intend to use it. Perhaps I don't see the problem clearly.

      test->function; print "$test::yeah\n"; package test; sub function { our $yeah = 7; }

      I don't see how it limits you, but I do see a clear benefit: I like it better than use vars.

      -Paul