Skip to content

Instantly share code, notes, and snippets.

@miyagawa
Created May 28, 2009 22:02
Show Gist options
  • Save miyagawa/119608 to your computer and use it in GitHub Desktop.
Save miyagawa/119608 to your computer and use it in GitHub Desktop.
package Versions;
require 5.006;
our $VERSION = 0.01;
my @modules;
# flag if we're in END { }
my $in_end = 0;
sub import {
shift;
unshift @INC, sub {
my($self, $file) = @_;
return if $in_end;
push @modules, file2mod($file);
return;
};
}
sub file2mod {
local $_ = shift;
s/\.pm$//;
s!/!::!g;
return $_;
}
END {
$in_end = 1;
for my $module (@modules) {
my $version = $module->VERSION || "(undefined)";
print "$module $version\n";
}
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment