#!/pro/bin/perl

use strict;
use warnings;

use Date::Manip;
use Data::Peek;
use File::Find;
my $pod;
find (sub { $_ eq "perllocal.pod" and $pod //= $File::Find::name }, @INC);

$pod or die "Cannot find perllocal.pod\n";

my %m;
open my $ph, "<", $pod or die "Cannot open pod: $!\n";
local $/ = "\n=back\n";
while (<$ph>) {
    m{=head2
	\s+       (.*?) \s* :	# Date
	\s+ C<\s* (.*?) \s* >	# Type
	\s* L<\s* (.*?) \s* \|	# Module name
	}x or next;
    my ($date, $type, $mod, $lt, $vsn, $exe, $id) = ($1, $2, $3, "", "", "", "");
    m{      installed\s+into \s*:\s* (.*)      }x and $id  = $1;
    m{C<\s* LINKTYPE         \s*:\s* (.*?) \s*>}x and $lt  = $1;
    m{C<\s* VERSION          \s*:\s* (.*?) \s*>}x and $vsn = $1;
    m{C<\s* EXE_FILES        \s*:\s* (.*?) \s*>}x and $exe = $1;
    push @{$m{$mod}}, {
	date		=> [ UnixDate ($date, "%s"), $date ],
	version		=> $vsn,
	type		=> $type,
	linktype	=> $lt,
	exe_files	=> $exe,
	inst_dir	=> $id,
	};
    }
close $ph;

DDumper \%m;
