* Dan Sugalski (dan / sidhe.org) wrote:
> At 6:00 AM +0900 9/7/02, Paul Duncan wrote:
> >I'm suspicious of anything Larry, or any of the top Perl brass, have to
> >say regarding scoping rules.  Variable declaration in Perl is a
> >nightmare: do you use "my", "our", "local", or a filehandle?
> 
> Erm... only my and our are declarations. local is not. And you'd use 
> a filehandle presumably when you wanted to read or write from a file 
> of some sort.

True.  I guess what I'm really trying to say is this: despite the
additional complexity and inconsistent behavior, Perl's scoping rules
are not really that much more powerful than Ruby's scoping rules.

The reason I tossed in file handles?  I was using them to illustrate how
various types in Perl have scoping nuances which cause unexpected
behavior and give unexpected results.  Case in point:

use strict;                              # no more implicit variables
open HeyImStillImplicit, "filename.txt"; # okay!!???
open $foo, "filename.txt";               # nope sorry

# this is okay:
my $foo;
open $foo, "filename.txt";

# but this isn't:
my FILEHANDLE;
...

> There are a few operations in perl that only act on global variables, 
> rather than lexical ones (notably local, symbolic refs, and formats). 
> Perl's appendix--vestigial remnants of an older time. Every language 
> has them, and they're generally marked as deprecated.

Neither symbolic references nor the local keyword are marked as
depricated.  To be fair, local says "you should probably be using my()".

> I'd hardly call anything in perl nefarious, though. Well, with 
> perhaps the exception of the source to the regex engine, but all 
> regex engine code is evil.
> -- 
>                                         Dan
> 
> --------------------------------------"it's like this"-------------------
> Dan Sugalski                          even samurai
> dan / sidhe.org                         have teddy bears and even
>                                       teddy bears get drunk

-- 
Paul Duncan <pabs / pablotron.org>        pabs in #gah (OPN IRC)
http://www.pablotron.org/               OpenPGP Key ID: 0x82C29562