gzayzay has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I am a Perl rookies that seek you wisdom. I am working on a project and I need to parse around some variables to separate modules I have created.
Example:
I have multiply mudules that I will like to use the various file modes that I have define in this module say called "moduleA". In moduleB that is locate in a separate file, I use the following code;use strict; use var qw($readMode $writeMode $appendMode); $readMode = ''; $writeMode = '>'; $appendmode = '>>'; sub openFile { my $mode = pop(@_) open(FILENAME, $mode, EXPR); }
Whenever I run the code, I see the following error "Global symbol "$readMode" requires explicit package name at ..." Could any Monk kindly fill me with wisdom? note, I don't want to $readMode by way of a subroutine. Thanksuse strict; require "moduleA.pl"; openFile("someOtherStuff", $readMode);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Using Global Variables in Perl
by samtregar (Abbot) on Apr 22, 2008 at 16:57 UTC | |
Re: Using Global Variables in Perl
by pc88mxer (Vicar) on Apr 22, 2008 at 17:12 UTC | |
Re: Using Global Variables in Perl
by TGI (Parson) on Apr 22, 2008 at 17:50 UTC | |
Re: Using Global Variables in Perl
by mscharrer (Hermit) on Apr 22, 2008 at 17:18 UTC | |
Re: Using Global Variables in Perl
by gzayzay (Sexton) on Apr 22, 2008 at 17:37 UTC | |
Re: Using Global Variables in Perl
by FunkyMonk (Chancellor) on Apr 22, 2008 at 22:53 UTC | |
by jkva (Chaplain) on Apr 23, 2008 at 11:07 UTC | |
by Anonymous Monk on Sep 06, 2011 at 02:52 UTC |
Back to
Seekers of Perl Wisdom