#!/usr/bin/perl # Formatear las fechas # Copyright O.Sotolongo (asqwerty@gmail.com) 2020 use strict; use warnings; my $num_args = $#ARGV + 1; die "Should supply input filename\n" unless $num_args; my $ifile=$ARGV[0]; my $ofile; if ($num_args == 2){ $ofile=$ARGV[1]; }else{ ($ofile = $ifile) =~ s/\.\w{2,4}$/_proper/; $ofile =$ofile.'.csv'; } open IDF, "<$ifile"; open ODF, ">$ofile"; while () { if(/^.*,.*,\d{8}$/) { my ($shit, $date) = /^(.*),(\d{8})$/; (my $cdate = $date) =~ s/(\d{4})(\d{2})(\d{2})/$3.$2.$1/; print ODF "$shit,$cdate\n"; }else{ print ODF; } } close ODF; close IDF;