in reply to Changing a Date format

The secret of dealing with dates in Perl is to convert your value into an "epoch seconds" value. You can do that using timelocal from Time::Local. In your case, it would be done like this (assuming your data line is in $_):

use Time::Local; # get date and time my ($date, $time) = (split /\|/)[4, 5]; # get dmy my ($d,$m,$y) = split /\//, $date; # get hours & mins my ($hr, $min) = split /:/, $time; # convert year and month into 'correct' forms $y -= 1900; --$m; # get epoch (use 0 for seconds) my $epoch = timelocal(0, $min, $hr, $d, $m, $y);

The easiest way to get formatted dates from epoch seconds is to use POSIX::strftime, like this:

use POSIX 'strftime'; my $fmt_date = strftime('%Y-%m-%d', localtime($epoch));

Please don't use Date::Manip unless you can't find any other way to do what you want. It's a huge inefficient module and using it will really slow your script down.

--
<http://www.dave.org.uk>

Perl Training in the UK <http://www.iterative-software.com>