Skip to content

Instantly share code, notes, and snippets.

@spiculator
Created August 16, 2013 16:34
Show Gist options
  • Save spiculator/6251427 to your computer and use it in GitHub Desktop.
Save spiculator/6251427 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use warnings;
my $i = 1;
my @in = <>;
while(@in) {
local $_;
$_ = shift @in or die;
s/^(\d+)(\r?)$/$i$2/ or die "number of line expected: $_";
print;
++$i;
$_ = shift @in or die;
/\d\d:\d\d:\d\d,\d\d\d --> \d\d:\d\d:\d\d,\d\d\d\r?$/ or die "time expected: $_";
print;
my $lines = 0;
for(;;) {
$_ = shift @in or die;
print;
++$lines;
last if /^\r?$/;
}
$lines or die "empty sub";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment