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!
In reply to What am I doing wrong here? by ginju75
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |