The idea is to interweave the output of a pp just after the code position where pp was called.
Actually the following code IS the output of itself (well stripping the POD of former calls is still needed)
Might help producing code examples for the monastery...
use Data::Dump; use Data::Dumper; sub LINENUMBERS(){0} my %output; my $order=0; sub pp { my($package,$file,$line)=caller; $output{$file}{$line}=Data::Dump::pp(@_); } END { #print Dumper( \%output),"\n"; for my $file (keys %output){ my $h_lines=$output{$file}; #print Dumper($h_lines),"\n"; open my $f_code,"<",$file; while (my $line=<$f_code>){ print "$.: " if LINENUMBERS; print "$line"; if (exists $h_lines->{$.}) { print <<"__POD"; =output_pp $h_lines->{$.} =cut __POD } } } } $a++; pp($a); =output_pp 1 =cut $a++; pp($a); =output_pp 2 =cut $a++; pp($a); =output_pp 3 =cut
Cheers Rolf
|
|---|