diff --git a/lib/Subtitle/SRT.pm b/lib/Subtitle/SRT.pm index bd36027..c5ddff8 100644 --- a/lib/Subtitle/SRT.pm +++ b/lib/Subtitle/SRT.pm @@ -121,21 +121,20 @@ sub parse { sub build { my ($self) = @_; - my ($hrs, $min, $sec, $msec, $out); + my (@lines, $out); - $out = ''; foreach my $e (@{ $self->{events} }) { - $out .= $e->{id} . "\n"; + push @lines, $e->{id}; my $start = sprintf $self->{timing_fmt}, make_timing($e->{timing}->[0]); my $end = sprintf $self->{timing_fmt}, make_timing($e->{timing}->[1]); - $out .= sprintf "%s --> %s\n", $start, $end; - $out .= "$e->{text}\n"; - $out .= "\n"; + push @lines, sprintf("%s --> %s", $start, $end); + push @lines, $e->{text}; + push @lines, ""; } - return $out; + return join($self->{eol} => @lines); } 1;