----- Original Message -----
From: "Peter Eisengrein" <[EMAIL PROTECTED]>
To: "'Ron Grabowski'" <[EMAIL PROTECTED]>; "Perl-Win32-Users Mailing List
(E-mail)" <[EMAIL PROTECTED]>
Sent: Tuesday, March 06, 2001 10:06 AM
Subject: RE: strict frustration
> Sorry, I didn't give any code because it is a fairly large program.
However,
> I do have
> my @array;
>
> at the top of the script (and nowhere else; actually it's my @SORT), yet I
> get the error telling me it requires explicit package name. Why do I have
to
> explicitly tell it @main::SORT if it was declared in main and doesn't
exist
> anywhere else???
>
> I do now understand the value in using it, until something like this
> happens.
>
Try the following:
print "Sub affects main\n\n";
@sort = ("b", "a", "c");
print "\n\tmain - ";
for (@sort){print "\t$_,";}
&asub(@sort);
print "\n\tmain - ";
for (@sort){print "\t$_,";}
print "\n\nSub doesn't affects main\n\n";
@sort = ("b", "a", "c");
print "\n\tmain - ";
for (@sort){print "\t$_,";}
&bsub(@sort);
print "\n\tmain - ";
for (@sort){print "\t$_,";}
print "\n\nSub returns values to main\n\n";
my ($sortedref, $unsortedref) = &csub(@sort);
my @sorted = @$sortedref;
my @unsorted = @$unsortedref;
print "\n\tmain - ";
for (@sorted){print "\t$_,";}
print "\n\tmain - ";
for (@unsorted){print "\t$_,";}
sub asub
{
@sort = sort @_;
print "\n\tasub -";
for (@sort){print "\t$_,";}
$sort[1] = x;
print "\n\tasub -";
for (@sort){print "\t$_,";}
}
sub bsub
{
my @sort = sort @_;
print "\n\tbsub - ";
for (@sort){print "\t$_,";}
print "\n\tbsub - ";
$sort[1] = x;
for (@sort){print "\t$_,";}
}
sub csub
{
my @unsorted = @_;
print "\n\tcsub - ";
for (@unsorted){print "\t$_,";}
my @sorted = sort @unsorted;
print "\n\tcsub - ";
for (@sorted){print "\t$_,";}
return(\@sorted, \@unsorted);
}
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users