Collecting my attempts to improve at tech, art, and life

Perl Hacks In My Workspace

Tags: perl coolnamehere

Looking at some specific hacks from the O’Reilly Perl Hacks book for my own Perl workflow. It should be obvious from the tone and content that this is not intended to replace any of the original material or take credit for anything in the book.

Perl Hacks is a great book. I catch something new every time I open it. That’s at least partly because I still haven’t read it from cover to cover. The “Hacks” series of books is written in such a way that cover-to-cover reading is not needed, thankfully.

The browser hacks from the beginning are an especially convenient way to add some Perl-friendly functionality to [Firefox][]. One minor issue is that I spend a lot of my time in ELinks, a text-based Web browser. Why? Well, most of my work is done over an ssh connection, so I’m already using gnu-screen and Vim. Keeping my Web browser within my screen session reduces context switching. screen also keeps my sessions alive, so everything including my ELinks browser session is intact when I come back to my workspace the next morning.

Naturally, I had to examine Hack #1 in the context of ELinks.

Hack #1: Add CPAN Shortcuts to ELinks

There are a couple of preliminary steps to get out of the way before adding CPAN shortcuts to ELinks. First, install ELinks. Second, make sure smart prefixes are enabled.

The first requirement for this hack is ELinks. The ELinks download page shows all sorts of nifty ways to install it. I went the easy way and just used my system package managers.

That’s apt-get on Ubuntu Linux:

$ sudo apt-get install elinks

Or MacPorts on OS X:

$ sudo port install elinks

Windows folks are left to their own devices, since most of my Windows elinks usage is on other systems via Putty. I do know that ELinks is available in cygwin.

Enable Smart Prefixes

The easiest way to test if smart prefixes are enabled is by trying to use one that’s already been defined. Try opening the following URL in ELinks:

g Modern::Perl

The resulting page should look something like this. Follow these steps if that is not the case:

Now go back and try to open g Modern::Perl again. That did the trick for me.

On to the CPAN shortcuts.

Adding a Smart Prefix

The Smart Prefixes

Description Prefix URL
Search CPAN cpan http://search.cpan.org/search?mode=module;query=%s
Show Module Documentation cpod http://search.cpan.org/perldoc/%s
AnnoCPAN Module Documentation apod http://www.annocpan.org/?mode=search;field=Module;latest=1;name=%s

Try Them Out!

Try the following URLs to get you started.

References


Added to vault 2024-01-15. Updated on 2024-01-26