#!/usr/bin/perl use warnings; use strict; use Date::Parse; # 799107 my $data = ''; while ( ) { # print $_; $data = $_; chomp ($data); if ($data =~ /^DATE:\s+(\w{3}, \d+ \w{3} \d{4} \d\d:\d\d:\d\d) ([+-]\d{4})/ ) { my $date = $1; # Don't do this; check existence of $1 my $zone = $2; # and $2 before you try to use them! print "'Date' found: $date which converts to: "; my $time = str2time($date); print "$time Zone Offset: $zone\n"; print "\t Restringified: " . localtime($time) . "\n"; # reconvert, solely as a check on above } } =head OUTPUT 'Date' found: Sat, 9 Feb 2008 17:14:18 which converts to: 1202595258 Zone Offset: -0730 Restringified: Sat Feb 9 17:14:18 2008 'Date' found: Sun, 10 Feb 2008 04:23:55 which converts to: 1202635435 Zone Offset: +0400 Restringified: Sun Feb 10 04:23:55 2008 =cut __DATA__ SUBJECT: test FROM: John Smith DATE: Sat, 9 Feb 2008 17:14:18 -0730 TO: Joe Doe additional for demo only DATE: Sun, 10 Feb 2008 04:23:55 +0400