Permalink
Browse files

Add a tool to standardize Jifty->serial values in output files, for e…

…asirt diff'ing
  • Loading branch information...
alexmv committed Apr 2, 2010
1 parent d5e0e4f commit 0cf9e37b9358fd938d248401575bc700042f8c1f
Showing with 30 additions and 0 deletions.
  1. +30 −0 utils/un-serial.pl
View
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+for my $file (@ARGV) {
+ my $read;
+ unless (open($read, "<", $file)) {
+ warn "Can't open $file: $!";
+ next;
+ }
+ my $lines = do {undef $/; <$read>};
+ close $read;
+
+ my $s = 1;
+ while ($lines =~ /\b(S\d{6,}_\d{5,})/) {
+ my $replace = $1;
+ $lines =~ s/$replace/S$s/g;
+ $s++;
+ }
+
+ $file .= ".unserial";
+ my $write;
+ unless (open($write, ">", $file)) {
+ warn "Can't open $file for writing: $!";
+ next;
+ }
+ print $write $lines;
+ close $write;
+}

0 comments on commit 0cf9e37

Please sign in to comment.