Well, not for all "like" strings, but for exactly that format, I'd do something like
use Time::Local;
my $str = '2007/07/17 13:21';
my @t = $str =~ m!(\d{4})/(\d{2})/(\d{2})\s(\d{2}):(\d{2})!;
$t[1]--;
my $timestamp = timelocal 0,@t[4,3,2,1,0];
# verify...
print scalar localtime $timestamp;
__END__
Tue Jul 17 13:21:00 2007
before looking up any module of CPAN. Things would be different if I had to convert disparate formats.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|