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;