Paul Lalli wrote:
If you type:
use strict;
at the top of your program, Perl will force you to "fully qualify" all
of your global variables.  That is, to name them with their package
name in addition to the actual variable name.  So the variable $foo in
package main must actually be called $main::foo.   Therefore, it is
standard best practice to 'use strict;' and to only use lexical
variables (ie, declared with my).  That way, if you accidentally typo
a variable name, Perl can no longer assume you're talking about a
different (global) variable, because that variable would have to be
fully qualified, and Perl can therefore give you a compile-time error,
so you can find your bug.

You should avoid fully qualified variables for the same reasons you have `use 
strict;` in all your programs.  Use 'our' or 'use vars' to bring package 
variables into scope.

You can have typos with fully qualified variables:
#!/usr/bin/perl

use strict;
use warnings;

$main::foo = 'bar';
print "$mian::foo\n"
__END__


--
Just my 0.00000002 million dollars worth,
 Shawn

"For the things we have to learn before we can do them, we learn by doing them."
 Aristotle

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to