Q:

How can I convert a date to epoch time?

I have a huge formatted file of the form:
29/01/2010 18:00 string1 string2 .....

30/01/2010 18:30 string3 string4 .....

...

...

dd/mm/yyyy hh:MM strings strings....

I need to perform some statistics based on the dates.
So I would like to substitute the string dd/mm/yyyy hh:MM with epoch time in the file in order to perform simple manipulations. 
I suppose that the best way is to use Perl, but I really don't know where to start. Any hints?

A:

Just that? This quick-and-dirty one-liner should do:
perl -MPOSIX -pwe 's{^(\d{2})/(\d{2})/(\d{4}) (\d{2}):(\d{2}) }{mktime(0,$5,$4,$1,$2-1,$3-1900)." "}e;'

Feed it the file on standard input and it will output the changed version to standard output. All it does is look for lines that have "dd/mm/yyyy hh:mm " at the start, and feed the date components to the mktime function from the POSIX module to get a unix timestamp.

