#!/usr/bin/perl -w use strict; use Time::Local; my $in_file="default.db"; my $out_file="properdates.db"; my ($sec, $min, $hr)=0; my @fmt_date=''; my @new=''; open (IN,"$in_file")||die "Sorry, but I can't open the file:$!"; open (OUT,">$out_file")||die "Sorry, but I can't append the file:$!"; while(){ chomp; my @line=split(/\|/); my @date=(split/\|/)[1,14,15]; foreach my $i (@date){ if ($i){ #my ($d, $m, $y)=split/\//, $date[$i]; my ($d, $m, $y)=split/\//, $i; $y-=1900; --$m; my $epoch=timelocal($sec, $min, $hr, $d, $m, $y); ($fmt_date[$i])=strftime('%d-%b-%Y', localtime($epoch)); } #end if } #end foreach push @new, qq($line[0]|$fmt_date[0]|$line[2]|$line[3]|$line[4]|$line[5]|$line[6]|$line[7]|$line[8]|$line[9]|$line[10]|$line[11]|$line[12]|$line[13]|$fmt_date[1]|$fmt_date[2]|$line[16]|$line[17]|$line[18]); push @new, "\n"; } #end while print OUT "@new"; close IN; close OUT;