The first part of the snippet goes at the top of your script.
The second part goes where you want to list the modules and versions. Sample output looks like:
Tk 804.027
Tk::Event 4.015
Tk::Event::IO 4.008
AutoLoader 5.60
DynaLoader 1.05
Tk::Submethods 4.004
Encode::Unicode 1.40
use strict;
use warnings;
BEGIN {our @usedModules; unshift @INC, sub {push @usedModules, [@_]; r
+eturn undef;}}
our @usedModules;
...
my $versions = '';
for (@usedModules) {
my $name = $_->[1];
$name =~ s/\..*//;
$name =~ s|[\\/]|::|g;
my $version = eval{eval "\$$name\::VERSION"};
$versions .= "$name \t$version\n" if defined $version;
}
print $versions;