in reply to mying arrays?
I am very suprised that you have never seen a script that uses my to scope an array. It is used to scope a variable to enclosing brackets (or Main if there are no enclosing brackets).
Consider the following VERY contrived example:
#!/usr/bin/perl -w use strict; my @array; # no enclosing braces - scoped to Main my $var1 = 3; my $var2 = 4; foreach (1..10) { push @array , $_; } if ($var2 > $var1) { my @array = ($var1 , $var2); print "$_\n" foreach (@array); } print "Other array\n"; print "$_\n" foreach (@array);
This allows you to use the same variable name numerous times within the same program without stepping on each other. It should not be confused with local, which I will leave you to read the Perl docs to grok.
Cheers - L~R
|
|---|