Opening POD docs in Preview.app
If you're a Perl hacker on Max OS X, you probably find yourself referring to POD docs quite a bit. I usually use TextMate for viewing POD of the current module I'm looking at, (Command-control-p) but TextMate's pod2html viewer only allows one document at a time, This is often about 5 or 6 too few. The "perldoc" command has sort of a similar issue unless you want to have a large number of terminal windows open.
So if you fall into that category, you'll want to get pod2pdf and its associated libraries. Unpack and install it[1]. Then, add the following little useful function to your .bash_profile or some script that is executed upon login.
# Convert, cache and open POD docs in Preview.app
podview() {
# Customize the path to your POD PDF directory
POD=~/Documents/PODmodule="$@"
moduledir=`echo $module | sed -E 's/[:\/]+/_/g' \
| sed -E 's/^[\._]+//g' \
| sed -E 's/\.p[lm]$//g'`
if [ ! -e "$POD" ]; then
mkdir $POD
fi
if [ ! -e "$POD/$moduledir.pdf" ]; thenperldoc -T -u $module > $POD/$moduledir
pod2pdf $POD/$moduledir; rm $POD/$moduledir
fi
open -a Preview "$POD/$moduledir.pdf"
}
After that, all you have to do is type "podview Some::Perl::Module" and it will be automatically opened in Preview as a PDF. In addition, the PDF is cached in ~/Documents/POD (by default) to speed up the process or loading it or even finding it with, say, QuickSilver?
[1] - Don't forget the actual pod2pdf wrapper script which is also included in the distribution but not installed via make install. Put it somewhere in your path.
Comments