Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
to this one:1 00:00:38,585 --> 00:00:40,519 What's wrong? 2 00:00:40,554 --> 00:00:43,148 I think I hit something.
so, i wrote this script to do the job, but im having problems and its prolly some blatantly obvious thing i cant see cause i wrote it...please help:#1 00;00;38;59 00;00;40;52 What's wrong? #2 00;00;40;55 00;00;43;15 I think I hit something. #3 00;00;43;92 00;00;45;41 You think it's a rock?
open(IN,"./$file"); @infile = <IN>; 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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: text reformatting woes
by ysth (Canon) on Apr 19, 2004 at 07:32 UTC | |
|
Re: text reformatting woes
by kvale (Monsignor) on Apr 19, 2004 at 09:11 UTC | |
|
Re: text reformatting woes
by ysth (Canon) on Apr 19, 2004 at 08:06 UTC | |
|
Re: text reformatting woes
by matija (Priest) on Apr 19, 2004 at 07:35 UTC | |
|
Re: text reformatting woes
by Anonymous Monk on Apr 19, 2004 at 07:54 UTC | |
by ysth (Canon) on Apr 19, 2004 at 08:02 UTC | |
by Anonymous Monk on Apr 19, 2004 at 08:04 UTC | |
by ysth (Canon) on Apr 19, 2004 at 08:13 UTC | |
|
Re: text reformatting woes
by Anonymous Monk on Apr 19, 2004 at 18:51 UTC |