Last active
December 29, 2015 09:58
-
-
Save tommybutler/7653376 to your computer and use it in GitHub Desktop.
Fix all the bad dates in your CPAN changes file and get it right with the formal specification. This code assumes your dates aren't so mangled that they can't be parsed by Time::ParseDate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cp Changes Changesx ; grep -P '^\d' Changes | perl -MTime::ParseDate -nE 'chomp; $_ =~ s/.*?\s//; $orig = $_; $_ = Time::ParseDate::parsedate( $_ ); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( $_ ); $mon+=1; $year+=1900; say sprintf "%4d-%02d-%02d | $orig", $year, $mon, $mday;' | while read parseddate; do echo "$parseddate" | perl -MFile::Util -E '$file = shift @ARGV; $ftl = File::Util->new; $content = $ftl->load_file( $file ); undef $/; $swap = <>; chomp $swap; ( $good, $bad ) = split / \| /, $swap; $content =~ s/\Q$bad\E/$good/smg; $ftl->write_file( $file => $content )' Changesx; echo "$parseddate"; done | |
# the fixed file is in "Changesx" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes yes I know the loop should have been in the Perl code. Blech.