At 10:59 AM 4/19/02 -0400, KEVIN ZEMBOWER wrote: >What module would folks recommend to do some math on Date/Time strings? >There's so many to choose from in CPAN, I'm not sure where to start. > >I'm interested in processing a web server log, which has a data format >like: >gw243.carlson.com - - [01/Feb/2002:17:18:54 -0500] "GET >/images/line1mmc.gif HTTP/1.0" 200 966 "-" "Mozilla/3.01 (compatible;)" >gw243.carlson.com - - [01/Feb/2002:17:18:57 -0500] "GET >/pr/l10/l10chap4.stm HTTP/1.0" 200 4954 "-" "Mozilla/3.01 >(compatible;)" >gw243.carlson.com - - [01/Feb/2002:17:18:58 -0500] "GET >/images/line1mmc.gif HTTP/1.0" 200 966 "-" "Mozilla/3.01 (compatible;)" > >I'm trying to output an ad-hoc report which would say something like >"gw243.carlson.com requested /images/line1.mmc.gif at 17:18:54. >Requested second file, /pr/l10/l10chap4.stm 3 seconds later, then >requested third file 1 second after that...." I'm trying to determine >from the times between requests and the presence of subsequent files >whether requests are made for a particular file in error. > >Would this be most easily done with a perl module, and which one, or >just by using the built-in perl functions?
Behold the power of Date::Parse: $ perl -MDate::Parse -le 'print scalar localtime(str2time"01/Feb/2002:17:18:54 -0500")' Fri Feb 1 14:18:54 2002 See, it even incorporated the timezone offset (and took into account daylight savings time and my own timezone - now you can tell what timezone I am in :-). If you don't want it to do that, don't give it that part of the string. In case it's not clear, str2time (imported by Date::Parse) returns a Unix time (seconds past 1970). localtime was just a convenient way of illustrating that. -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]