« Bike Ruminations | Main | State Department Religious Freedom Report »

Handy perl Functions for ZSH

The following ZSH functions, once added to ~/.zshrc and loaded, allow convenient lookup of Perl module versions and locations.

function pm-version { perl -M$1 -le "print \$$1::VERSION" } function pm-path { perl -l -M$1 \ -e "(\$mp=q{$1})=~s{::}{/}g;\$mp.=q{.pm};" \ -e "print \$INC{\$mp}" }

For example:

$ pm-version Text::Template 1.44 $ pm-path Text::Template /home/jmates/lib/perl5/Text/Template.pm

This leads to quick perldoc(1) lookups or viewing of module source code:

$ pm-path Text::Template /home/jmates/lib/perl5/Text/Template.pm $ perldoc `!!` … $ less !$

More perl tricks available in Perl One Liners.

Technorati Tags: ,