From b851efc8e1fa275b1170e72bbc41b165b09882b7 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Tue, 17 Mar 2015 14:58:25 +1000 Subject: [PATCH] + Subtitle::SRT->build --- lib/Subtitle/SRT.pm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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;