Browse Source

* Subtitle::Utils : minor optimizations

master
Alex 'AdUser' Z 6 years ago
parent
commit
f2d257510e
  1. 12
      lib/Subtitle/Utils.pm

12
lib/Subtitle/Utils.pm

@ -16,11 +16,11 @@ our %EXPORT_TAGS = (
timing => [qw(make_timing parse_timing)], timing => [qw(make_timing parse_timing)],
); );
## string sunctions ## string functions
sub chomp_all { sub chomp_all {
return unless @_; return unless $_[0];
return $_ =~ s/[\r\n]+$//o for @_; $_[0] =~ s/[\r\n]+$//o;
} }
sub strip_bom { sub strip_bom {
@ -29,8 +29,8 @@ sub strip_bom {
} }
sub trim { sub trim {
return unless @_; return unless $_[0];
$_ =~ s/(^\s+|\s+$)//go for @_; $_[0] =~ s/(^\s+|\s+$)//go;
} }
## timing functions ## timing functions
@ -101,9 +101,9 @@ Subtitle::Utils -- usefull generic routines
=head2 C<chomp_all> =head2 C<chomp_all>
chomp($line); chomp($line);
chomp($line1, $line2);
In-place strips newlines (CR/LF) from line. In-place strips newlines (CR/LF) from line.
Differs from standart chomp() than strips '\r', '\n' and it's combinaion, disregarding $/
=head2 C<strip_bom> =head2 C<strip_bom>

Loading…
Cancel
Save