Discovering the magic... Perl!

Estimated reading time: 2 minutes

Warning

This blog post is older than 4 years and its content may be out of date.

Heya folks, long time no see, eh? Well, it’s been crazy around here and I had a bunch of stuff to do, mostly related to studying. Anyways, half an hour ago I discovered the magic of Perl! After skimming through some of the man-pages and perl-doc, I managed to wrap up some nice, little scripts. Given the fact that Perl is ubiquitous available on most Unix/Linux boxes, this could prove to be a quite handy tool. Fun fact: seems like Ruby got some of it’s syntactic sugar derived from Perl; I have a programming task in Ruby on Rails at hand and the similarities in syntax caught my attention. Maybe that lead to the quick feeling of success? Examples are e.g. unless (negated if), until (negated while) and the “foo if bar;” syntax Quick example from one of the tutorials contained in the man-pages (read them, they are very thorough!):

#!/usr/bin/env perl
use strict;
use warnings;

open(NET, "| netstat -tulpn"); # pipe the output of netstat -tulpn into NET
while() { print $_; }; # print every line of NET
close(NET); # close the handle

This is just one small example how one could use Perl to write scripts or even more sophisticated tools. One of my plans is still to write a small package manager for my LFS hobby, and as Perl is already there in a LFS build this could come in quite handy. Although pacman from Arch Linux is one of the best an KISS package managers I have met, I like the challenge of actually writing an application that I’d probably use “every day”. What are your experiences with Perl? Good night fellas!