#!/usr/bin/perl -s ## ## pev -- Perl Extension Version. ## ## Reports the installation status and version of a Perl Extension Module (.pm) ## ## Copyright (c) 1999-2000, Vipul Ved Prakash. All rights reserved. ## This code is free software; you can redistribute it and/or modify ## it under the same terms as Perl itself. ## ## $Id$ use Data::Dumper; my $class = shift || die "syntax: pev [-f] [-v] [-vv] modulename\n"; $module = $class; $module =~ s#::#/#g; $module = "$module.pm"; eval { require $module } || die "$class not installed.\n"; eval { $version = $class->VERSION } || print "Version information not available for "; print "$class $version\n"; $v = 1 if defined $vv; my (@PM, @STAT) if $v; if ( $f ) { print "[$INC{$module}]\n" } if ( $v ) { my $file = $INC{$module}; print "\nFilename\n\t$file\n"; open PM, $file || die $!; @PM = ; @STAT = stat( PM ); close PM; $proc = depends_on ( \@PM ); $auth = author ( \@PM ); print "Size\n\t$#PM lines"; print ", $STAT[7] bytes" if $vv; print "\n"; $"="\n\t"; print "Dependencies\n\t@$proc\n"; print "Author\n\t$auth\n"; print "Installation\n\t" . localtime($STAT[9]) . "\n" if $vv; } sub depends_on { my @mods; grep {s/^\s*(?:require|use)\s+(\S+)\s*;\s*$/$1/i && push @mods,$1}@{$_[0]}; return \@mods; } sub author { my ( $author ) = (join '', @{$_[0]}) =~ m/^\=head1\s+AUTHORS?\s*\n\n\s*?(.*?)\n/ims; $author = "Author name not available." unless $author; $author =~ s/^\s*//; $author=~ s/I<(.*?)>/$1/; return $author; } "True Value"; =head1 NAME pev - report perl extension installation status and version. =head1 SYNOPSIS pev Digest::MD5 pev -v Text::Template pev -f Carp pev -vv Crypt::Random =head1 DESCRIPTION pev extracts and reports metadata from installed perl modules. `installed' means any module visible to the perl interpreter on your machine, i.e. under one of the directories in @INC as compiled in lib_perl. perl C<-V> lists these directories. Without options, pev reports the version number of specified perl module, or a "not installed" error message. C<-v> additionally reports complete pathname of the .pm file that contains the module, size of this file in lines, dependencies (the modules included with use/require statements) and name/email of the author. C<-vv> makes C<-v> more verbose. C<-f> reports just the pathname. =head1 AUTHOR Vipul Ved Prakash, I =cut