#!/usr/bin/perl use strict; use warnings; use DateTime; use DateTime::Format::Strptime; my $file = $ARGV[0] or die "Need to get CSV file on the command line\n"; my $outfile = "output_date.txt"; my $sum = 0; open(my $data, '<', $file) or die "Could not open '$file' $!\n"; open (OUTFILE, "> $outfile") || die "ERROR: opening $outfile\n"; while (my $line = <$data>) { chomp $line; my @fields = split "\t" , $line, -1;; my $formatter= new DateTime::Format::Strptime(pattern => '%Y%m%d%T'); my $sum1 = "$formatter->parse_datetime($fields[2])"; my $sum2 = "$formatter->parse_datetime($fields[3])"; $fields[2] = "$sum1"; $fields[3] = "$sum2"; # $line= print join( "\t", @fields ) . "\n" ; print OUTFILE "@fields\n"; } close ($data); close (OUTFILE);