diff --git a/lib/Subtitle/SRT.pm b/lib/Subtitle/SRT.pm index ca84972..9ba0321 100644 --- a/lib/Subtitle/SRT.pm +++ b/lib/Subtitle/SRT.pm @@ -115,4 +115,20 @@ sub parse { return scalar @{ $self->{events} }; } +sub build { + my ($self) = @_; + my $out = ""; + + foreach my $e (@{ $self->{events} }) { + $out .= "$e->{id}\n"; + $out .= sprintf "%s --> %s\n", + $self->build_timing($e->{timing}->[0], 3, ','), + $self->build_timing($e->{timing}->[1], 3, ','); + $out .= "$e->{text}\n"; + $out .= "\n"; + } + + return $out; +} + 1;