How can I see the values of the variables from a Perl trace? -


my target debug (step step) sample.pl script below.

the problem: don’t real values of variables ($top_number , $x , $total).

my question: how see real integer values of ($top_number , $x , $total) trace output?

what needs change in perl -d:trace in order numbers, , not: $top_number , $x , $total ?

example trace output:

[root@linux /tmp]# perl -d:trace ./sample.pl  >> ./sampl.pl:9: $top_number = 100; >> ./sampl.pl:10: $x = 1; >> ./sampl.pl:11: $total = 0; >> ./sampl.pl:12: while ( $x <= $top_number ) { >> ./sampl.pl:13:       $total = $total + $x;   # short form: $total += $x; >> ./sampl.pl:14:       $x += 1;                # follow short form? >> ./sampl.pl:13:       $total = $total + $x;   # short form: $total += $x; >> ./sampl.pl:14:       $x += 1;                # follow short form? >> ./sampl.pl:13:       $total = $total + $x;   # short form: $total += $x; >> ./sampl.pl:14:       $x += 1;                # follow short form? . .  [root@linux /tmp]#more sample.pl script  #!/usr/bin/perl    $top_number = 100; $x = 1; $total = 0; while ( $x <= $top_number ) {     $total = $total + $x;   # short form: $total += $x;     $x += 1;                # follow short form? }  print "the total 1 $top_number $total\n"; 

i assume want see values of $x , $total variables each iteration through loop. there no indication pod devel::trace can that.

however, devel::dumptrace can.

perl -d:dumptrace ./sample.pl  >>>>> hw.pl:7:      $top_number:100 = 100; >>>>> hw.pl:8:      $x:1 = 1; >>>>> hw.pl:9:      $total:0 = 0; >>>>> hw.pl:10:     while ( $x:1 <= $top_number:100 ) { >>>>> hw.pl:11:         $total:1 = $total:0 + $x:1;   # short form: $total:0 += $x:1; >>>>> hw.pl:12:         $x:2 += 1;                # follow short form? >>>>> hw.pl:11:         $total:3 = $total:1 + $x:2;   # short form: $total:1 += $x:2; >>>>> hw.pl:12:         $x:3 += 1;                # follow short form? >>>>> hw.pl:11:         $total:6 = $total:3 + $x:3;   # short form: $total:3 += $x:3; 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -