From 8ecca08a6d84ec10c4098f8a7016729c7a76e3ce Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Mon, 23 Jul 2018 17:49:17 +1000 Subject: [PATCH] * Subtitle::BASE : add to_string() and to_file() --- lib/Subtitle/BASE.pm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/Subtitle/BASE.pm b/lib/Subtitle/BASE.pm index 3e65e50..36439f7 100644 --- a/lib/Subtitle/BASE.pm +++ b/lib/Subtitle/BASE.pm @@ -42,6 +42,21 @@ sub from_file { return $self->parse(\@lines); } +sub to_string { + my ($self) = @_; + return $self->build; +} + +sub to_file { + my ($self, $path) = @_; + open my $FH, '>', $path + or return $self->log(error => "can't open file: $path -- $!"); + print $FH $self->build; + close $FH; + + return 1; +} + 1; =pod