Below I'm just swapping 'Oct 1977' to '1977 Oct' it works OK. But I want to also change Oct to 10. So I want to process and swap so, 'Oct 1977' becomes '1977-10'.
Actually I want to change it to the form for a MYSQL date data type : 'YYYY-MM-DD'. So I also want to put in a dummy day so, 1977-10-01 is what I really want. How do I swap and process with regex?
Another hassel, It's a dirty file and there some fields that are just 1977 and I want 1977-01-01 in that case ...any help appreciated.
Lee G.
while (<INFILE>) {
chomp;
$zapvar = $_;
$zapvar =~
s/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(19\d{2})/$2 $1/;
print OUTFILE "$zapvar\n";
}
Actually I want to change it to the form for a MYSQL date data type : 'YYYY-MM-DD'. So I also want to put in a dummy day so, 1977-10-01 is what I really want. How do I swap and process with regex?
Another hassel, It's a dirty file and there some fields that are just 1977 and I want 1977-01-01 in that case ...any help appreciated.
Lee G.
while (<INFILE>) {
chomp;
$zapvar = $_;
$zapvar =~
s/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(19\d{2})/$2 $1/;
print OUTFILE "$zapvar\n";
}