#!/usr/bin/perl -s
while (<STDIN>) {

chomp;
next if /^[\d]*$/;
if (($start,$end) = /([\d:,]*) --> ([\d:,]*)/) {
	my(@dialogue) = ();
	$starttime = &hrminsec_to_frame($start);
	$endtime = &hrminsec_to_frame($end);
	$_ = <STDIN> or last;
	chomp;
	while (not /^[\d]+$/) {
		my(@temp) = split /\*newline\*/;
		push(@dialogue,$_) unless /^#/;
		$_ = <STDIN> or last;
		chomp;
	}
	pop(@dialogue);
	my $dialogue = join("\\\\\n",@dialogue);
	$dialogue =~ s/\*newline\*/\\\\\n/g;
	print "$starttime $dialogue\n";
	print "$endtime\n\n";
}

}

sub hrminsec_to_frame {
	if ($framerate == 0) { $framerate = 30000/1001; }
	my($time) = @_;
	$time =~ s/,/./g;
	my($hr,$min,$sec) = split(':',$time);
	my $offset = ($hr*3600+$min*60+$sec);
	if ($delay) { $offset += $delay; }
	return int(($offset)*$framerate);
}
