T
Todd
The dynamic scope is a slightly different defined compared with the
lexical scope when considier only the end boundary of the scope. Let
check the codes below:
#! /bin/perl -l
my $a1 = "old value";
if (my $a1 = "new value") {};
print "case `my' after <if block>: $a1";
our $a2 = "old value";
if (our $a2 = "new value") {};
print "case `our' after <if block>: $a2";
local $a3 = "old value";
if (local $a3 = "new value") {};
print "case `local' after <if block>: $a3";
local our $a4 = "old value";
if (local our $a4 = "new value") {};
print "case `local our' after <if block>: $a4";
__END__
case `my' after <if block>: old value
case `our' after <if block>: new value
case `local' after <if block>: new value
case `local our' after <if block>: new value
So here only the `my' variable decarlared in the condition expr of
<if block> totally disapeared after the if block.
May some one here give any hints on this?
Best regards,
Todd
lexical scope when considier only the end boundary of the scope. Let
check the codes below:
#! /bin/perl -l
my $a1 = "old value";
if (my $a1 = "new value") {};
print "case `my' after <if block>: $a1";
our $a2 = "old value";
if (our $a2 = "new value") {};
print "case `our' after <if block>: $a2";
local $a3 = "old value";
if (local $a3 = "new value") {};
print "case `local' after <if block>: $a3";
local our $a4 = "old value";
if (local our $a4 = "new value") {};
print "case `local our' after <if block>: $a4";
__END__
case `my' after <if block>: old value
case `our' after <if block>: new value
case `local' after <if block>: new value
case `local our' after <if block>: new value
So here only the `my' variable decarlared in the condition expr of
<if block> totally disapeared after the if block.
May some one here give any hints on this?
Best regards,
Todd