open(IN,"./$file"); @infile = ; close(IN); open(OUT,">$file-FORMATTED.txt"); @sections = split(/\n/, @infile); foreach $i (@sections) { ($l1,$l2,@l3) = split(/\n/,$i); $output = "#",chomp($l1); $l2 =~ s/(\d\d)\:(\d\d)\:(\d\d),(\d\d\d) --> (\d\d)\:(\d\d)\:(\d\d),(\d\d\d)/\1;\2;\3;\4 \5;\6;\7;\8/; $x = $4; $y = $8; if(substr($x,2,1) > 5) { $x = substr($x,0,2); $x++; } else { $x = substr($x,0,2); } if(substr($y,2,1) > 5) { $y = substr($y,0,2); $y++; } else { $y = substr($y,0,2); } $l2 =~ s/(\d\d;\d\d;\d\d;)\d\d\d (\d\d;\d\d;\d\d;)\d\d\d/\1$x \2$y/; $output .= "$l2\n", join("\n",@l3), "\n"; print OUT $output; undef $l1; undef $l2; undef $x; undef $y; undef @l3; } close(OUT);