Perl : Counting occurences of IP addresses in Apache logs

Tuesday, March 2nd, 2010

This Perl one-liner is intended to print the 10 most frequent client IP addresses in an Apache log file. It can easily be recycled to count anything, though.
(more…)

Perl+Twitter : Getting @mentions from command line

Sunday, January 24th, 2010

This code snippet demonstrates how easy it is to collect your twitter @mentions in Perl, coupled with curl for simplicity.
(more…)

Perl : Using the Finance::Quote module to get your stock prices

Wednesday, December 30th, 2009

Finance::Quote is a Perl module which can be used to obtain stock information from various internet sources. I thought I’d rather share this code snippet as an example showing how easy it is to use, before I turn it into a bloatware with an SQL backend to compute average price per share and what not :-)

So here is a simple snippet demonstrating how to get the price of a stock :
(more…)

D-Bus introduction in Perl

Sunday, March 8th, 2009

As stated in Wikipedia :

D-Bus (Desktop Bus) is a simple inter-process communication (IPC) system for software applications to communicate with one another.

This post provides a simple code snippet in Perl to help you getting started with D-Bus programming. (more…)

Perl : Convert time from Epoch to local time

Thursday, March 6th, 2008

watch

This little Perl one-liner can get handy when you need to translate “time in seconds since the Epoch” (for example in logs) to local time :

% perl -e 'print scalar(localtime(1202484725)), "\n";'
Fri Feb  8 16:32:05 2008
%

This was pretty useful today when browsing through Nagios event logs, where times are given in seconds from the Epoch.

By the way, the Epoch is defined as 00:00 UTC on January, 1st, 1970.