From 8c61671e539954fd2d716116e4e8eee80cc10c34 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Thu, 19 Feb 2015 22:33:27 +1000 Subject: [PATCH] * Subtitle::SRT : use BASE --- lib/Subtitle/SRT.pm | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/lib/Subtitle/SRT.pm b/lib/Subtitle/SRT.pm index 7c943dd..a19e676 100644 --- a/lib/Subtitle/SRT.pm +++ b/lib/Subtitle/SRT.pm @@ -5,6 +5,8 @@ use warnings; use feature qw(switch); use utf8; +use base 'Subtitle::BASE'; + sub new { my ($class, %args) = @_; my $self = { @@ -18,26 +20,6 @@ sub new { return bless($self, $class); } -sub trim { - my ($self, $line) = @_; - return unless defined $line; - return $line =~ s/(^\s+|\s+$)//or; -} - -sub log { - my ($self, $level, $msg) = @_; - - given ($level) { - when ("error") { push @{ $self->{log} }, "E: $msg"; } - when ("warn") { push @{ $self->{log} }, "W: $msg"; } - when ("info") { push @{ $self->{log} }, "I: $msg"; } - when ("debug") { push @{ $self->{log} }, "D: $msg" if $self->{debug}; } - default { warn "Unknown loglevel $level of $msg\n"; } - } - - return 1; -} - sub parse_timing { my ($self, $str) = @_; my $time = 0.0; @@ -81,7 +63,7 @@ sub parse { foreach my $line (@$lines) { $linenum++; - $line =~ s/[\r\n]+$//o; # chomp + $line = $self->chomp($line); # expected: event id if ($line and not $event) { $event = $self->new_event;