On Sunday 20 January 2002 21:00, Damian Conway wrote:
> Bryan C. Warnock asked:
> > Since the parentheses are no longer required, will the expressions
> > lose or retain their own scope level?  (I'm assuming that whatever
> > rule applies, it will hold true if you do elect to use parantheses
> > anyway.)
>
> Err. Expressions don't have their own scope level, even in Perl 5.

They do in block conditional expressions.  Try this:

    #!/your/path/to/perl -w
    my $x = 4;

    if (my $x = 5) {
        print "$x\n";
        my $x = 6;
        print "$x\n";
    } elsif (my $x = 7) {
        print "$x\n";
        my $x = 6;
        print "$x\n";
    } else {
        print "$x\n";
        my $x = 6;
        print "$x\n";
    }

    print "$x\n";     

"my" variable $x masks earlier declaration in same scope at Perl/demo.pl 
line 9.   # the elsif masking the if
Found = in conditional, should be == at Perl/demo.pl line 9.
Found = in conditional, should be == at Perl/demo.pl line 5.
5
6
4

-- 
Bryan C. Warnock
[EMAIL PROTECTED]

Reply via email to