You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
711 B

package Subtitle::BASE;
use strict;
use warnings;
use feature qw(switch);
use utf8;
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 chomp {
my ($self, $line) = @_;
return unless defined $line;
return $line =~ s/(^\xEF\xBB\xBF|[\r\n]+$)//ogr;
}
sub trim {
my ($self, $line) = @_;
return unless defined $line;
return $line =~ s/(^\s+|\s+$)//or;
}
1;