On Thu, May 22, 2008 at 5:57 AM, Octavian Rasnita <[EMAIL PROTECTED]>
wrote:

> Hi,
>
> I've tried the following script and it works fine:
>
> use strict;
> my $text = 1;
> my $text = 2;
> print $text;
>
> Shouldn't perl disallow defining the $text variable a second time in the
> same script if using "use strict"?


Probably not, as already has been said.

And, as said, the use of: use warnings; *will* warn you.

Next shows a block or lexical scope (mask does not happen) versus when in
the same scope (in global, not using a separate scope block) where mask can
happen.

#!/usr/bin/perl
use strict;
use warnings;
my $text = 1;
# begin block next
{my $text = 2;
print "In block we have ",$text,"\n";}
# block ended on previous line
# so, next is outside of block
print "1st Outside block we have ",$text,"\n";
my $text = 3;
print "2nd Outside block we have ",$text,"\n";
# end

-- 
Alan.

Reply via email to