Help with perl code understanding

Hi,

I need to understand below perl code, can some one advise me.


perl -MDate::Parse -e'BEGIN{$main::now=time;$main::old=(time-60*30)}' -nE'if(/^(\w+\s+\d+\s+\d+:\d+:\d+)/) {$t=str2time $1; $t > $old && $t < $now && print}'

This code is watching STDIN for a particular string pattern - "A word","one or more spaces","a number""one or more spaces","3 numbers separated by colons"

This is of a form that looks like it could be a date and time:
eg March 16 12:00:00

It sets $now to be the current time and $old to be 30 minutes ago.
It then figures out a unix timestamp from the supplied date string, and if that date is newer that 30 mins ago and older then now (ie if it's in the last 30 mins) it prints the date to the screen. Otherwise it does nothing.

I'd imagine that if you piped a file into this, it would output only the lines that have a datestamp in them in the last 30 minutes.

Note that if your system clock is in a different timezone to that of the file you are piping in, it won't work correctly.