$ cat -n tt
1 #!/usr/bin/perl
2
3 my $perl = <<'EOF';
4 sub {
5 my $x = 123;
6 $x += shift;
7 print "x is $x\n"
8 }
9 EOF
10
11 my $cf = eval $perl;
12
13 $cf->(4);
$ perl -d tt
Loading DB routines from perl5db.pl version 1.28
Editor support available.
Enter h or `h h' for help, or `man perldebug' for more help.
main::(tt:3): my $perl = <<'EOF';
main::(tt:4): sub {
main::(tt:5): my $x = 123;
main::(tt:6): $x += shift;
main::(tt:7): print "x is $x\n"
DB<8> s
main::(tt:11): my $cf = eval $perl;
DB<8> s
main::((eval 20)[tt:11]:7): ;
####
DB<8> p $#{"_<(eval 20)[tt:11]"}
7
DB<9> l (eval 20)
1 sub {
2: my $x = 123;
3: $x += shift;
4: print "x is $x\n"
5 }
6
7==> ;
####
DB<10> s
main::(tt:13): $cf->(4);
DB<10> p $#{"_<(eval 20)[tt:11]"}
-1
####
DB<11> p join "\n", map { "$_ $#{$_}" } grep /_<\(/, keys %::
_<(eval 20)[tt:11] -1
_<(eval 22)[/usr/lib/perl5/5.8.8/SelfLoader.pm:38] 6
_<(eval 11)[/usr/lib/perl5/5.8.8/SelfLoader.pm:111] 1
_<(eval 12)[/usr/lib/perl5/5.8.8/SelfLoader.pm:38] 40
_<(eval 5)[/usr/lib/perl5/5.8.8/Term/ReadLine.pm:306] -1
_<(eval 21)[/usr/lib/perl5/5.8.8/SelfLoader.pm:38] 10
_<(eval 23)[/usr/lib/perl5/5.8.8/SelfLoader.pm:38] 20
_<(eval 26)[/usr/lib/perl5/5.8.8/perl5db.pl:628] 4
DB<13> f eval 22
Choosing (eval 22)[/usr/lib/perl5/5.8.8/SelfLoader.pm:38] matching `eval 22':
1 package readline; sub F_PreviousHistory {
2: &get_line_from_history($rl_HistoryIndex - shift);
3 }
4
5
6 ;
####
DB<14> f eval 20
Choosing (eval 20)[tt:11] matching `eval 20':
DB<15> l
####
DB<15> s
main::CODE(0x97b7d28)((eval 20)[tt:11]:2):
2:
DB<15>
main::CODE(0x97b7d28)((eval 20)[tt:11]:3):
3:
DB<15>
main::CODE(0x97b7d28)((eval 20)[tt:11]:4):
4:
DB<15>
x is 127
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.