Skip to content

Instantly share code, notes, and snippets.

@hirose31 hirose31/example
Last active Jan 4, 2016

Embed
What would you like to do?
pmver - Utility shell function for checking version of an arbitrary Perl module
$ pmver Carp
1.26
/home/hirose31/perlbrew/perls/perl-5.16.3/lib/5.16.3/Carp.pm
$ pmver -cd Carp
1.26
/home/hirose31/perlbrew/perls/perl-5.16.3/lib/5.16.3/Carp.pm
$ pwd
/home/hirose31/perlbrew/perls/perl-5.16.3/lib/5.16.3
pmver () {
do_cd=
if [ "$1" = '-cd' ]; then
do_cd=1
shift
fi
module=$1
perl -M${module} -e "print \$${module}::VERSION,\"\n\""
fullpath=$(
perldoc -ml ${module} 2>/dev/null
[ $? -eq 255 ] && perldoc -l ${module}
)
echo $fullpath
if [ "$do_cd" = '1' ]; then
\cd $(dirname $fullpath)
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.