Last active
January 24, 2025 08:40
-
-
Save hirose31/8647156 to your computer and use it in GitHub Desktop.
pmver - Utility shell function for checking version of an arbitrary Perl module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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