in reply to Global variables in Perl

In laymen's terms, you're declaring two variables named $DEBUG.
our $DEBUG; <-- 1 use ConfigThisJunk qw ( $DEBUG ); <-- 2

The print sees the former. Get rid of our $DEBUG; in the main pacakge.

As an aside, I suggest you change

our $DEBUG = 1;
to
use vars qw( $DEBUG ); $DEBUG = 1;
in order to avoid spurious "used only once" warnings if you decide to do
use ConfigThisJunk; print $ConfigThisJunk::DEBUG;

Replies are listed 'Best First'.
Re^2: Global variables in Perl
by taioba (Acolyte) on Jun 03, 2010 at 19:07 UTC

    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...

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