Alex 'AdUser' Z
10 years ago
1 changed files with 34 additions and 0 deletions
@ -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…
Reference in new issue