1#!/usr/bin/perl -w
2
3package check_perldiag;
4
5# ABSTRACT: check a localized version of L<perldiag> for consistency
6
7use strict;
8use warnings;
9
10use Pod::Find  ();
11use Pod::POM   ();
12
13my $localized_perldiag = $ARGV[0];
14
15die "No perldiag specified" unless $localized_perldiag;
16
17my $localized_pod_filename = Pod::Find::pod_where({-inc => 1}, $localized_perldiag);
18my $default_pod_filename = Pod::Find::pod_where({-inc => 1}, 'perldiag');
19
20my $parser = Pod::POM->new();
21my $pom_local = $parser->parse_file($localized_pod_filename);
22if (!$pom_local) {
23	die "Could not parse localized perldiag: " . $parser->error();
24}
25
26my $pom_default = $parser->parse_file($default_pod_filename);
27if (!$pom_default) {
28	die "Could not parse default perldiag: " . $parser->error();
29}
30
31my (@local_errors, @default_errors);
32foreach my $item ($pom_local->head1->[1]->over->[0]->item) {
33	push @local_errors, $item->title;
34}
35
36foreach my $item ($pom_default->head1->[1]->over->[0]->item) {
37	push @default_errors, $item->title;
38}
39
40if ($#local_errors != $#default_errors) {
41	print "Unequal number of errors: localized - $#local_errors, default - $#default_errors.\n";
42}
43
44for (my $i = 0; $i <= $#local_errors; $i++) {
45	if ($local_errors[$i] ne $default_errors[$i]) {
46		print 'Got: "' . $local_errors[$i] . '", expected: "' . $default_errors[$i] . '".' . "\n";
47	}
48}
49
50__END__
51
52=head1 NAME
53
54check_perldiag - check a localized version of perldiag for consistency
55
56=head1 SYNOPSIS
57
58From the command line:
59
60	check_perldiag POD2::FR::perldiag
61
62=head1 DESCRIPTION
63
64This script compares a translated version of L<perldiag> with the default L<perldiag> installed with perl. It compares each error message in the two files and tells you if they do not match. A warning is issued if the two files contain a different number of error messages defined.
65