From: Gunnar Hjalmarsson <nore...@gunnar.cc>
> Jenda Krynicky wrote:
> > From: "Chas. Owens" <chas.ow...@gmail.com>
> >> On Tue, Apr 28, 2009 at 13:38, Gunnar Hjalmarsson <nore...@gunnar.cc> 
> >> wrote:
> >> snip
> >>>> Fully qualified names do not trip strict.  Which is a reason to avoid
> >>>> using them.  I once work at a place that wrote Perl 5 as if it were
> >>>> still Perl 4.  They had turned on strict because they had heard it was
> >>>> the right thing to do, but their response to it failing their scripts
> >>>> was to move to using only fully qualified variables.
> >>> A few years ago I made that same mistake in a rather large Perl program, 
> >>> and
> >>> I believe that my mistake was caused by the fact that that was just what
> >>> Perl requested me to do.
> >>>
> >>> $ perl -Mstrict -e'$var=""'
> >>> Global symbol "$var" requires explicit package name at -e line 1.
> >>> Execution of -e aborted due to compilation errors.
> 
> > Well, the first thing the message says is that the "$var" is a global 
> > symbol. That's the first thing you should be thinking about. Do I 
> > want the variable to be global? OK, if I wanted it to be global I 
> > would add the explicit package, but I do not want it to be global. 
> > What do I do?
> 
> That's easy to say when you know the difference. At the time I did not. 
> I just wanted to turn on strict in order to prepare the program for 
> mod_perl.
> 
> The message wording may well mislead beginners IMNSHO. At least those 
> who are not 'smarter' than me. ;-)

It's hard to tell now, but I believe I knew the difference between a 
global and local variable (in the normal meaning of the word) at 
latest when playing with Pascal back when I was about 15.

But maybe I was never confused by this message because I first looked 
for a way to declare local variables and quite a bit later introduced 
use strict. As a way to help find typos and accidental globals. So to 
me this message always meant "hey, either you've mistyped or you 
never declared the variable".

I think the original problem is with using use strict because 1. 
someone told you to or 2. you were told you have to do so for 
mod_perl. It's not really "use strict" that's required by mod_perl.

In either case what wording would you suggest?

Maybe

'$var' not declared, requires explicit package name if global

?

Though I bet people will be confused in cases like

 perl -Mstrict -e 'local $var = 4'

because quite a few people think "local $foo" is a declaration.

Jenda 

===== je...@krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to