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

Re^3: Global variables in Perl

by ikegami (Patriarch)
on Jun 03, 2010 at 19:10 UTC ( [id://842979]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Global variables in Perl
in thread Global variables in Perl

I had to include the 'our' or 'use var' statement so that Perl wouldn't croak a 'Global symbol "$DEBUG" requires explicit package name at...' error.

Not so.

$ cat ConfigThisJunk.pm package ConfigThisJunk; use strict; use warnings; BEGIN { use Exporter; our @ISA = qw( Exporter ); our @EXPORT_OK = qw( $DEBUG ); } our $DEBUG = 1; 1; $ perl -wle'use strict; use ConfigThisJunk qw( $DEBUG ); print $DEBUG' 1

I believe the second one is deprecated now

Yeah, ignore that. They both have their uses. Think of it as "'our' is a better choice if both 'use vars' and 'our' fits your needs".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-26 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found