Thanks, got it :-)
One more question about lexical variables. If I define a lexical variable in a block, what happens to the memory storing the value of the lexical variable after the code exits the block?
For example, in the script below. I cannot directly access $tricky outside the block. But it can be done with a reference. My question is if the memory storing the contents of $tricky has been released right after the block ends? If so, does it mean some other programs can write to that memory and when I try to retrieve the value of $tricky with a reference after the block, I may get something unexpected(memory got overwritten by other program)?
#!/usr/bin/pere
my $reference;
{
my $tricky = "TRICKY";
$reference = \$tricky;
}
print "\$tricky is not defined\n" unless $tricky ;
# What happens to the memory storing the contents of $tricky?
# Has the memory storing $tricky been released?
print "Using a reference, here you are: $$reference\n";