Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
You can keep the template right inside the program, and do the medium lifting with Template instead of Perl, like so:
my %d; while (<DATA>) { my ($file, $line, $comment) = /^([^:]+):(\d+)\s+(.*)/ or warn("unknown line, skipping: $_"), next; push @{$d{$file}{$line}}, $comment; } use Template; Template->new->process(\<<'EOT', { d => \%d, env => \%ENV }) [%# USE Dumper; Dumper.dump(d); -%] [%- FOREACH filek = d.keys.sort; filev = d.$filek; FOREACH linek = filev.keys.nsort; linev = filev.$linek; "<dt>$filek</dt><dd><b> line $linek</b>\n"; FOREACH comment = linev; " <ul>\n" IF loop.first; " <li>"; comment | html; "</li>\n"; " </ul>\n" IF loop.last; END; "</dd>\n"; END; END; -%] EOT or die Template->error; __END__ comment_tmpl.tt2:1 This would be more readable if I turned on Template +'s space-stripping options. comment_reader.pl:31 More informative error message would probably be +good. comment_reader.pl:71 Need a better explanation of data structure. annotate.el:1 Should properly be in a mode... annotate.el:11 Should be configurable variable annotate.el:13 Formatting should be configurable in variable annotate.el:11 Should automatically make "annotations" visible if it i +sn't already annotate.el:21 Control-c keys are supposed to be for mode-specifics...
which generates:
annotate.el
line 1
  • Should properly be in a mode...
annotate.el
line 11
  • Should be configurable variable
  • Should automatically make "annotations" visible if it isn't already
annotate.el
line 13
  • Formatting should be configurable in variable
annotate.el
line 21
  • Control-c keys are supposed to be for mode-specifics...
comment_reader.pl
line 31
  • More informative error message would probably be good.
comment_reader.pl
line 71
  • Need a better explanation of data structure.
comment_tmpl.tt2
line 1
  • This would be more readable if I turned on Template's space-stripping options.

-- Randal L. Schwartz, Perl hacker


In reply to •Re: Annotating Files by merlyn
in thread Annotating Files by stephen

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (5)
    As of 2014-12-28 14:04 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (181 votes), past polls