The Time::Piece lines are not working. I'm not getting any errors, but they are not changing the Date within the DATETIME variable for each record from MM/DD/YYYY 00:00 to YYYY-MM-DD 00:00 as I need. What am I missing here?while($line = <$FH>) { # split the fields, concatenate the first three fields, # and add it to the beginning of each line in the file chomp($line); my @fields = split(/,/, $line); unshift @fields, join '_', @fields[0..2]; $_ = join '-', (split /\//)[2,0,1] for $fields[14]; $_ = join '-', (split /\//)[2,0,1] for $fields[20]; $_ = join '-', (split /\//)[2,0,1] for $fields[23]; $_ = Time::Piece->strptime($fields[38],'%m/%d/%Y %H:%M')->strftime +('%Y-%m-%d %H:%M'); $_ = Time::Piece->strptime($fields[39],'%m/%d/%Y %H:%M')->strftime +('%Y-%m-%d %H:%M'); push @data, \@fields; }
Update
I have found the correct way to this - updated belowNow I've run into another problem for which I'll have to open a separate question!while($line = <$FH>) { # split the fields, concatenate the first three fields, # and add it to the beginning of each line in the file chomp($line); my @fields = split(/,/, $line); unshift @fields, join '_', @fields[0..2]; $_ = join '-', (split /\//)[2,0,1] for $fields[14,20,23]; $_ = Time::Piece->strptime($_,'%m/%d/%Y %H:%M')->strftime('%Y-%m-% +d %H:%M') for @fields[38,39]; push @data, \@fields; }
In reply to Formatting date while parsing CSV by BigRedEO
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |