Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Global variables in Perl

by taioba (Novice)
on Jun 03, 2010 at 19:07 UTC ( #842978=note: print w/ replies, xml ) Need Help??


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

Thanx monks! However, I had to include the 'our' or 'use var' statement (I believe the second one is deprecated now) so that Perl wouldn't croak a 'Global symbol "$DEBUG" requires explicit package name at...' error. If I remove 'use strict' AND the 'our'|'use var' statement I get the same 'Use of uninitialized value $DEBUG in print at...' message as before. Perhaps a bug with Exporter? I also tried Exporter-Lite without success...


Comment on Re^2: Global variables in Perl
Re^3: Global variables in Perl
by ikegami (Pope) on Jun 03, 2010 at 19:10 UTC

    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
Node Status?
node history
Node Type: note [id://842978]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (15)
As of 2014-07-29 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (213 votes), past polls