gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] Current CVS VC build crashes


From: Dave Denholm
Subject: Re: [gnugo-devel] Current CVS VC build crashes
Date: 23 Feb 2002 15:52:41 +0000

Trevor Morris <address@hidden> writes:

> I believe all of the trouble Arend had with regress.pl was because
> he's not using Perl 5.6.
> 
> 
> >>  - after fixing this, I get 
> >> 
> >> Global symbol "$curdir" requires explicit package name at ./regress.pl 
> >> line 855.
> >> Global symbol "$curfile" requires explicit package name at ./regress.pl 
> >> line
> >> 856.
> >> Global symbol "$CURDIR" requires explicit package name at ./regress.pl 
> >> line 857.
> >> Execution of ./regress.pl aborted due to compilation errors.
> >
> >
> >Quick fix is to take out a 'use strict' line at the top (assuming there is 
> >one)
> >
> >Better fix is to declare them as 'my' variables.
> >
> >my $curdir;
> >my $curfile;
> 
> I don't think this will work here.  These are used in a recursive function,
> using the "our" and "local" keywords, which, apparently, only work with
> Perl 5.6.  If they're defined with "my", they will get recursively clobbered.


Oops - just remembered I can see the source on savanah.

Hmm : 'our' is something I've not met before. 
And I can't find it the man pages :-(

I have a vague recollection that it declares a global variable that
can be shared across files in a package..?

If that's the case, perhaps  use vars qw($curdir $curfile $CURDIR)
is equivalent.


Ah - finally found it in perldelta

     "our" declarations

     An "our" declaration introduces a value that can be best
     understood as a lexically scoped symbolic alias to a global
     variable in the package that was current where the variable
     was declared.  This is mostly useful as an alternative to
     the `vars' pragma, but also provides the opportunity to
     introduce typing and other attributes for such variables.
     See the our entry in the perlfunc manpage.

and perlfunc

     our EXPR
             An `our' declares the listed variables to be valid
             globals within the enclosing block, file, or `eval'.
             That is, it has the same scoping rules as a "my"
             declaration, but does not create a local variable.
             If more than one value is listed, the list must be
             placed in parentheses.  The `our' declaration has no
             semantic effect unless "use strict vars" is in
             effect, in which case it lets you use the declared
             global variable without qualifying it with a package
             name.  (But only within the lexical scope of the
             `our' declaration.  In this it differs from "use
             vars", which is package scoped.)



So since this isn't a package, just a plain global should be fine.


But I'm not sure why you can't juse use  lexical variables inside the
loop, rather than local ?

I thought my was fine in a recursive function..?
>From perlvar man page

     Unlike dynamic variables created by the `local' operator,
     lexical variables declared with `my' are totally hidden from
     the outside world, including any called subroutines.  This
     is true if it's the same subroutine called from itself or
     elsewhere--every call gets its own copy.




Or you could even just access parameters from the $_[] array
directly, rather than copying into local variables.


dd
-- 
address@hidden          http://www.insignia.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]