From: "George P." <[EMAIL PROTECTED]>
> (taken frrom Programming Perl)
>
> __BEGIN__
>
> The our declaration declares a lexically scoped name
> for a global variable, which is not itself a lexical variable
>
> __END__
>
> The part about the variable not being lexical variable can be
> checked by printing $main::var.
>
> However, what do you mean by a lexically scoped name, and what's
> the use of giving a lexically scoped name to a package variable.
>
> I know that declaring a variable as 'our' won't give out compile
> errors when use strict 'vars'; has been used.
Yes that's the purpose of our(). The "lexicaly scoped name" means
that the "suppression of compile errors" is only done in the current
lexical scope. That is till the end of the block or file.
Try this:
use strict;
$main::x = "Hello";
print "$main::x\n";
{
our $x;
$x = 'Hi';
print "$x\n";
}
print "$x\n";
Do you see? It's OK to use the $x without package name in the block,
but not outside.
This allows you to specify that "here I want to work with this global
variable" and "here I don't".
Jenda
===== [EMAIL PROTECTED] === 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]