#!/usr/bin/perl -l { open my $foo, '>', $$ or die $!; print $foo; # GLOB(0x...) print ref $foo; # GLOB print *$foo; # *main::$foo print $foo "Test"; # Test > $$ } # The scope has ended. Because the lexical dies, the file is closed. # The (normally unreachable because of its invalid name) glob # *main::$foo still exists, because globals just don't die. # And they lived happily ev^U #### { open my $foo, '>', $$ or die $!; print $foo; # GLOB(0x...) print ref $foo; # GLOB print *$foo; # *main::$foo print $foo "Test"; # Test > $$ { open my $foo, '>',"$$.z" or die $!; print $foo; # GLOB(0x...) print ref $foo; # GLOB print *$foo; # *main::$foo <-- !!!!! print $foo "Test"; # Test > $$ } }