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


in reply to (tye)Re: "use vars" will remain (Re: Win32 EXPORT_OK problems)
in thread Win32 EXPORT_OK problems

Actually, I think our has one other advantage over use vars, aside from the very minor speed improvement. With our, as with my, declaration and initialization can be done in one step:
my $num = 7; our $str = 'Hello';
whereas with use vars, declaration and initialization must always be separate steps:
use vars qw/ $str /; $str = 'Hello';

Replies are listed 'Best First'.
(tye)Re2: "use vars" will remain (Re: Win32 EXPORT_OK problems)
by tye (Sage) on Dec 27, 2000 at 01:48 UTC

    declaration and initialization can be done in one step

    Ah, yes, but should they? Even I were to use our, I'd still be writing code like:

    our $var; BEGIN { $var= "Hello"; }
    to avoid the race condition between the compile-time declaration of the variable and the (possibly very delayed or non-existant) run-time initialization of the variable. This is only rarely a problem, but it still happens often enough that this habit has saved me enough time that I continue it.

            - tye (but my friends call me "Tye")