Browse Source

+ Subtitle::BASE

master
Alex 'AdUser' Z 10 years ago
parent
commit
06d2f2057f
  1. 34
      lib/Subtitle/BASE.pm

34
lib/Subtitle/BASE.pm

@ -0,0 +1,34 @@
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/[\r\n]+$//or;
}
sub trim {
my ($self, $line) = @_;
return unless defined $line;
return $line =~ s/(^\s+|\s+$)//or;
}
1;
Loading…
Cancel
Save