The quick answer is perldiag. If you still want just what you asked for -- a list of warnings by category, try the following one-liner:

perl -MData::Dumper -ne '$item=$1 if /^=item (.*)/; push @{$warnings{$1}}, $item if /\(W ([^)]*)\)/; END {print Dumper \%warnings}' /usr/share/perl/5.8/pod/perldiag.pod

(Make sure to adjust the location of perldiag as approprate to your system -- perldoc -l perldiag will show you where it is.)


You want to know how it works? Well, let's start by showing you the code that I left out (IE that the -n option implies). The simpilest way to do this, and to do some reformatting at the same time, is to use -MO=Deparse, as in perl -MO=Deparse,-p -MData::Dumper -ne '$item=$1 if /^=item (.*)/; push @{$warnings{$1}}, $item if /\(W ([^)]*)\)/; END {print Dumper \%warnings}' That gives:

use Data::Dumper; LINE: while (defined($_ = <ARGV>)) { $item = $1 if /^=item (.*)/; push @{$warnings{$1};}, $item if /\(W ([^)]*)\)/; sub END { print Dumper(\%warnings); } ; }
, which isn't quite readable. I'll change some things around to make it a bit more idiomatic.
use Data::Dumper; while (defined($_ = <ARGV>)) { if (/^=item (.*)/) { $item = $1; } if (/\(W ([^)]*)\)/) { push @{$warnings{$1}}, $item; } } print Dumper(\%warnings);

I got rid of some superflous semicolons, the unused label LINE, and changed FOO if BAR to if (BAR) {FOO}. Most importantly, I moved the sub END { } bit to where it actually gets run -- as the program is ending.

But it still doesn't do some things you shouldn't do in any program longer then one line, even though it's no longer a one-liner -- it needs warnings and strict.

use Data::Dumper; use warnings; use strict; my ($item, %warnings); while (defined($_ = <ARGV>)) { if (/^=item (.*)/) { $item = $1; } if (/\(W ([^)]*)\)/) { push @{$warnings{$1}}, $item; } } print Dumper(\%warnings);

So, now that we've changed it from a confusing little oneliner to a real program, can you figure out how it works? It runs through each line of the file provided on the command line, or standard input if none was given. If the line starts with =item and a space, we save the rest of the line in the variable $item for later. If it contains a begin-paren, followed by a W, a space, a bunch of non-parenthesis characters, and then an end paren, then we add the contents of $item to the end of the array-reference @{ ... } given in the slot of %warnings given by $1 (the bunch of non-parenthesis characters from the line we're on). Then, once we're finished with all the lines in the ARGV filehandle, we dump out %warnings.


Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).


In reply to Re: A list of warnings by category? by theorbtwo
in thread A list of warnings by category? by itub

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.