APM: global scope array doesn't seem to be global

jeremy jeremyb at univista.com
Wed May 7 08:25:12 CDT 2003


my @repeat = undef; 
and
my @repeat = ();

would both give me what I want.  I  have no reason to not use ().
Using () would be "cleaner" I suppose   ...possibly more logical too.



However,

my @repeat = undef;
and
@repeat =undef;

are not the same thing.  Since I declare @repeat at the top of the
script and outside of any other subs, the @repeat array is global in
scope.  But, if I use 'my' on the line that empties @repeat, then I just
created a second empty local @repeat array.
  
On Wed, 2003-05-07 at 05:36, Mike Stok wrote:
> On 6 May 2003, jeremy wrote:
> 
> > Sometimes it just takes talking about it...
> > 
> >   I had put 'my @repeat = undef' on lines 642 and 511.
> >  where it should have been '@repeat = undef'.
> 
> Why do you assign undef to the array.  Do you really mean to initialise it 
> to a single element array containing undef?
> 
>   my @repeat;
> 
> or
> 
>   my @repeat = ();
> 
> will give you a new empty array.
> 
> Mike




More information about the Austin mailing list