Question: sub foo { my $lex = $ _ [ 0 ] ; sub bar { print $lex ; } bar ( ) ;
sub foo
my $lex $;
sub bar
print $lex
;
bar;
foo; foo;
a What is the output? What is potentially surprising about the output?
b Modify the code to create a reference to an anonymnous local subroutine and verify that it creates closures correctly. give different examples
c Add the line "use diagnostics;" to the beginning of the original version of the program, and rerun the program. Based on the explanation this will give you, speculate as to how nested named subroutines are implemented in Perl
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
