--- /dev/null
+#!/usr/local/bin/perl -w
+
+use strict;
+
+no locale;
+
+my %items;
+my $item_key;
+
+$/ = '';
+
+while (<>) {
+ if (/^=item\s+(.+)/) {
+ # new item
+
+ $item_key = get_item_key($1);
+ $items{$item_key} .= $_;
+
+ } elsif (/^=back\b/) {
+ # no more items in this group
+
+ foreach my $item_key (sort keys %items) {
+ print $items{$item_key};
+ }
+
+ $item_key = undef;
+ %items = ();
+
+ print;
+
+ } elsif (defined $item_key) {
+ # part of the current item
+
+ $items{$item_key} .= $_;
+
+ } else {
+ # not part of an item
+
+ print;
+
+ }
+}
+
+if (keys %items) {
+ warn "Missing =back after final =item.\n";
+
+ foreach my $item_key (sort keys %items) {
+ print $items{$item_key};
+ }
+}
+
+
+# get the sortable key for an item
+sub get_item_key {
+ my($item) = @_;
+
+ # remove POD formatting
+ $item =~ s/[A-Z]<(.*?)>/$1/g;
+
+ # remove printf-style escapes
+ # note: be careful not to remove things like %hash
+ $item =~ s/%(?:[scg]|lx|#o)//g;
+
+ # remove all non-letter characters
+ $item =~ tr/A-Za-z//cd;
+
+ return lc $item;
+
+}
+
+__END__
+
+=pod
+
+=head1 NAME
+
+sort_perldiag.pl - Sort warning and error messages in perldiag.pod
+
+=head1 SYNOPSIS
+
+B<sort_perldiag.pl> I<file>
+
+=head1 DESCRIPTION
+
+B<sort_perldiag.pl> is a script for sorting the warning and error
+messages in F<perldiag.pod>. POD formatting, printf-style escapes,
+non-letter characters, and case are ignored, as explained in L<perldiag>.
+
+=cut
+
functioning as a class, but that package doesn't define that particular
method, nor does any of its base classes. See L<perlobj>.
-=item Can't locate PerlIO%s
-
-(F) You tried to use in open() a PerlIO layer that does not exist,
-e.g. open(FH, ">:nosuchlayer", "somefile").
-
=item Can't locate package %s for @%s::ISA
(W syntax) The @ISA array contained the name of another package that
doesn't seem to exist.
+=item Can't locate PerlIO%s
+
+(F) You tried to use in open() a PerlIO layer that does not exist,
+e.g. open(FH, ">:nosuchlayer", "somefile").
+
=item Can't make list assignment to \%ENV on this system
(F) List assignment to %ENV is not supported on some systems, notably
to check the return value of your socket() call? See
L<perlfunc/listen>.
-=item lstat() on filehandle %s
-
-(W io) You tried to do an lstat on a filehandle. What did you mean
-by that? lstat() makes sense only on filenames. (Perl did a fstat()
-instead on the filehandle.)
-
=item Lookbehind longer than %d not implemented in regex; marked by <-- HERE in m/%s/
(F) There is currently a limit on the length of string which lookbehind can
handle. This restriction may be eased in a future release. The <-- HERE
shows in the regular expression about where the problem was discovered.
+=item lstat() on filehandle %s
+
+(W io) You tried to do an lstat on a filehandle. What did you mean
+by that? lstat() makes sense only on filenames. (Perl did a fstat()
+instead on the filehandle.)
+
=item Lvalue subs returning %s not implemented yet
(F) Due to limitations in the current implementation, array and hash
(P) The compiler attempted to do a goto, or something weird like that.
-=item panic: yylex
-
-(P) The lexer got into a bad state while processing a case modifier.
-
=item panic: utf16_to_utf8: odd bytelen
(P) Something tried to call utf16_to_utf8 with an odd (as opposed
to even) byte length.
+=item panic: yylex
+
+(P) The lexer got into a bad state while processing a case modifier.
+
=item Parentheses missing around "%s" list
(W parenthesis) You said something like
(F) While under the C<use filetest> pragma, we cannot switch the real
and effective uids or gids.
+=item %s syntax
+
+(F) The final summary message when a C<perl -c> succeeds.
+
=item syntax error
(F) Probably means you had a syntax error. Common reasons include:
a perl4 interpreter, especially if the next 2 tokens are "use strict"
or "my $var" or "our $var".
-=item %s syntax
-
-(F) The final summary message when a C<perl -c> succeeds.
-
=item sysread() on closed filehandle %s
(W closed) You tried to read from a closed filehandle.
(F) There are no byte-swapping functions for a machine with this byte
order.
-=item Unknown "re" subpragma '%s' (known ones are: %s)
-
-You tried to use an unknown subpragma of the "re" pragma.
-
=item Unknown open() mode '%s'
(F) The second argument of 3-argument open() is not among the list
data Perl expected. Someone's very confused, or perhaps trying to
subvert Perl's population of %ENV for nefarious purposes.
+=item Unknown "re" subpragma '%s' (known ones are: %s)
+
+You tried to use an unknown subpragma of the "re" pragma.
+
=item Unknown switch condition (?(%.2s in regex; marked by <-- HERE in m/%s/
(F) The condition part of a (?(condition)if-clause|else-clause) construct
recognized by Perl inside character classes. The character was
understood literally.
+=item Unrecognized escape \\%c passed through
+
+(W misc) You used a backslash-character combination which is not
+recognized by Perl.
+
=item Unrecognized escape \\%c passed through in regex; marked by <-- HERE in m/%s/
(W regexp) You used a backslash-character combination which is not
literally. The <-- HERE shows in the regular expression about where the
escape was discovered.
-=item Unrecognized escape \\%c passed through
-
-(W misc) You used a backslash-character combination which is not
-recognized by Perl.
-
=item Unrecognized signal name "%s"
(F) You specified a signal name to the kill() function that was not
use the /g modifier. Currently, /c is meaningful only when /g is
used. (This may change in the future.)
+=item Use of freed value in iteration (perhaps you modified the iterated array within the loop?)
+
+(F) This is typically caused by code like the following:
+
+ @a = (3,4);
+ @a = () for (1,2,@a);
+
+You are not supposed to modify arrays while they are being iterated over.
+For speed and efficiency reasons, Perl internally does not do full
+reference-counting of iterated items, hence deleting such an item in the
+middle of an iteration causes Perl to see a freed value.
+
=item Use of *glob{FILEHANDLE} is deprecated
(D deprecated) You are now encouraged to use the shorter *glob{IO} form
generally because there's a better way to do it, and also because the
old way has bad side effects.
-=item Use of freed value in iteration (perhaps you modified the iterated array within the loop?)
-
-(F) This is typically caused by code like the following:
-
- @a = (3,4);
- @a = () for (1,2,@a);
-
-You are not supposed to modify arrays while they are being iterated over.
-For speed and efficiency reasons, Perl internally does not do full
-reference-counting of iterated items, hence deleting such an item in the
-middle of an iteration causes Perl to see a freed value.
-
=item Use of -l on filehandle %s
(W io) A filehandle represents an opened file, and when you opened the file