ginju75 has asked for the wisdom of the Perl Monks concerning the following question:
Please see the code below and let me know what I am doing wrong here.
sub values; @X; use strict; # P is a package which has some subroutines and variables that I need +to use in my script. use P qw( $CurDir $a2 &guest &guest2 ); my $test = "TEST"; my $testdir = "$CurDir/$test"; # QUESTION: Do I need to use 'my' for these variables? # ERROR: If I don't use 'my' I get the error saying that $test require +s explicit package name. # If I don't use 'my' don't they automatically become global? Are they + not available for use? &values(); &guest(); &guest2( @X, "$test"); # QUESTION: I get an error saying that @X requires explicit package na +me. # How are global variable defined in a perlscript and how can they be +used, for the stuff I am doing in this script? sub values{ @X = ( something something ); # QUESTION: Same error as above! Need Explicit Package name. }
What am I doing here? Why do I keep getting the errors as mentioned above. Don't these variables come under the main Package?
What can I do to resolve these conflicts?
Thank you for your wisdom.
A Learning Monk!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What am I doing here?
by iakobski (Pilgrim) on Dec 05, 2001 at 14:05 UTC | |
|
Re: What am I doing here?
by MZSanford (Curate) on Dec 05, 2001 at 14:39 UTC | |
|
Re: What am I doing here?
by andye (Curate) on Dec 05, 2001 at 15:42 UTC | |
by mce (Curate) on Dec 05, 2001 at 16:02 UTC |