in reply to debugging eval'd code with source (SOLVED)
The string (eval 8) is the "file" name of the eval. You can use that name to list the eval.main::((eval 8)[evals.pl:15]:1):
The following example with the debugger illustrates the point. I will use this listing:
See how the evals produce the "virtual filenames":pp2@nereida:~/src/perl/testing$ cat -n evals.pl 1 use strict; 2 use warnings; 3 4 my ($a, $b) = (1, 9); 5 6 my $x = eval q { 7 $a = 2; 8 $b = 3; 9 print "$b\n"; 10 $a+$b; 11 }; 12 13 14 15 my $y = eval '$a+$b'; 16 17 print "$y\n";
See it?. Now I try to stop at line 15pp2@nereida:~/src/perl/testing$ perl -wd evals.pl 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::(evals.pl:4): my ($a, $b) = (1, 9); DB<1> c 6 main::(evals.pl:6): my $x = eval q { main::(evals.pl:7): $a = 2; main::(evals.pl:8): $b = 3; main::(evals.pl:9): print "$b\n"; main::(evals.pl:10): $a+$b; DB<2> n main::((eval 6)[evals.pl:6]:2): $a = 2; DB<2> l (eval 6) 1 2==> $a = 2; 3: $b = 3; 4: print "$b\n"; 5: $a+$b; 6 7 ;
I fail because I am in file eval not in the main file:DB<3> c 15 Line 15 not breakable.
DB<4> f evals.pl 1: use strict; 2: use warnings; 3 4: my ($a, $b) = (1, 9); 5 6: my $x = eval q { 7 $a = 2; 8 $b = 3; 9 print "$b\n"; 10 $a+$b; DB<5> c 15 3 main::(evals.pl:15): my $y = eval '$a+$b'; DB<6> n main::((eval 8)[evals.pl:15]:1): $a+$b DB<6> l (eval 8) 1==> $a+$b 2 ; DB<7> c 5 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. DB<7>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: debugging eval'd code with source
by sharkey (Scribe) on Jul 09, 2008 at 18:01 UTC |