Net::SSH::Perl, Perlbrew and You

For all of the admins who threw their computer out the window and swore they would never use CPAN again when they tried to install Net::SSH::Perl, try the following two things:
1. Install the GMP library(not the perl one) apt-get install libgmp-dev
2. Use cpanm instead of cpan. i.e. cpanm Net::SSH::Perl

This should solve the following error:
GMP.xs:4:17: error: gmp.h: No such file or directory

Also, while I am talking about it, check out perlbrew. It allows you to easily set up self contained instances of perl for multiple versions and switch between them. The possible uses for this are nearly endless, but I find that it increases my “sense of adventure” when messing with perl modules and my environment since I am not affecting the system perl.

Perlbrew

Perl invocation options

I have known about perl invocation options for a while, and I have used them on several occasions. However, I’m not sure I understood just how far the rabbit hole goes.

Try the following:

perl -wnle 'print "Each line of the file is printed here $_";' foo #Process through each line.
perl -wpie 's/replace/with/g;' foo # sed -i replacement
perl -wnlae 'print $F[0]' foo # awk '{print $1}' replacement

The best part is that these go beyond just replacing existing shell commands because of all the powerful constructs that exist in perl. If you are interested in more of the same, check out the linked book. Now if you will excuse me I am going to go follow the white rabbit…