Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Global variables in Perl

by taioba (Novice)
on Jun 04, 2010 at 16:33 UTC ( #843156=note: print w/ replies, xml ) Need Help??


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

Thanks, ikegami! I guess the issue is with my installation of Perl. If I use DEBUG, it croaks at the use of a bareword when strict 'subs' is in use. I had tried 'use constant', before, it kept warning me that the subroutine DEBUG was re-defined somewhere, now the warning went away. But the idea of using a sub instead of a variable is indeed neat, as Ronald pointed out. I tried &DEBUG but it looks for main::DEBUG. I'll probably just declare $DEBUG lexically in all scripts and modules and assign the function stored in ConfigThisJunk.pm to that variable. Later, I'll switch to a Mac... Cheers!


Comment on Re^2: Global variables in Perl
Re^3: Global variables in Perl
by ikegami (Pope) on Jun 04, 2010 at 17:43 UTC

    Please stop making claims about the code that's been posted based on different code that wasn't posted.

    If I use DEBUG, it croaks at the use of a bareword when strict 'subs' is in use.

    I don't believe you, not if you import the symbol as shown in both your code and my code.

    I tried &DEBUG but it looks for main::DEBUG.

    You must not have imported the symbol as shown.

    I'll probably just declare $DEBUG lexically in all scripts and modules and assign the function stored in ConfigThisJunk.pm to that variable

    That's silly. Just use the function. Import it as shown if you don't want to use the full name.

      Well, I actually copied and pasted your code and still got those errors. I updated Exporter and even tried to use Exporter::Lite and got the same thing. If I try 'use strict qw(vars refs)' for instance, it warns 'Bareword found in conditional...' but it works fine aside from that. I'll try to run it in a Unix based machine and see what happens. At any rate, many thanks!

        It could be that you're not executing the script you think you are executing, or you're not using the module you think you are using.

        Please provide the output of the following:

        perl -wle'use ConfigThisJunk; print $INC{"ConfigThisJunk.pm"};' cat ConfigThisJunk.pm # Or whatever the previous line printed cat script.pl # Or whatever your script is called. perl script.pl # Or whatever your script is called.

        Or on a Windows build:

        perl -wle"use ConfigThisJunk; print $INC{'ConfigThisJunk.pm'};" type ConfigThisJunk.pm # Or whatever the previous line printed type script.pl # Or whatever your script is called. perl script.pl # Or whatever your script is called.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (13)
As of 2014-09-16 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (26 votes), past polls