Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: (tye)Re: "use vars" will remain (Re: Win32 EXPORT_OK problems)

by chipmunk (Parson)
on Dec 27, 2000 at 01:44 UTC ( #48352=note: print w/replies, xml ) Need Help??


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")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://48352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2020-02-19 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (81 votes). Check out past polls.

    Notices?