Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by chipmunk (Parson)
on Dec 27, 2000 at 01:44 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://48352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-19 22:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found