my $r = "set in file scope"; { print "at beginning of BLOCK value of \$r is: $r\n"; print "in conditional statement value of \$r is: $r\n" if my $r = "set in if condition"; print "at end of BLOCK value of \$r is: $r\n"; } print "after BLOCK value of \$r is: $r\n"; #### at beginning of BLOCK value of $r is: set in file scope in conditional statement value of $r is: set in file scope at end of BLOCK value of $r is: set in if condition after BLOCK value of $r is: set in file scope #### my $r = "set in file scope"; { print "at beginning of BLOCK value of \$r is: $r\n"; my $r = "set in BLOCK's scope but formerly: $r"; print "at end of BLOCK value of \$r is: $r\n"; } print "after BLOCK value of \$r is: $r\n"; #### at beginning of BLOCK value of $r is: set in file scope at end of BLOCK value of $r is: set in BLOCK's scope but formerly: set in file scope after BLOCK value of $r is: set in file scope #### my $r = "set in file scope"; *original = \$r; { my $r = "set in BLOCK scope"; print "\$r is: $r\n"; print "\$original is: $original\n"; } #### $r is: set in BLOCK scope $original is: set in file scope #### $x = 'x'; @x = qw(x x x); $y = 'y'; @y = qw(y y y); $z = 'z'; @z = qw(z z z); print "$x,@x : $y,@y : $z,@z\n"; *y = *x; print "$x,@x : $y,@y : $z,@z\n"; *z = \$x; print "$x,@x : $y,@y : $z,@z\n"; { local $x = 'lx'; local @x = qw(lx lx lx); print "$x,@x : $y,@y : $z,@z\n"; } #### x,x x x : y,y y y : z,z z z x,x x x : x,x x x : z,z z z x,x x x : x,x x x : x,z z z lx,lx lx lx : lx,lx lx lx : x,z z z