The following code is just a Q&D proof of concept of Re^2: sorting a table columns using hashes (weaving output).

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

UPDATE: Hmm ...could be used for regression tests...

In reply to weaving output into code by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.