Permalink
Browse files

Use String::Trim to provide trim()

  • Loading branch information...
1 parent a3689e8 commit 681bb09cdc28d83c07f2eeca720e2dfed3f550a4 @doherty committed Nov 27, 2010
Showing with 7 additions and 13 deletions.
  1. +1 −1 CHANGES
  2. +5 −11 lib/Lingua/Boolean.pm
  3. +1 −1 t/00-init.t
View
@@ -1,7 +1,7 @@
Revision history for Perl module Lingua::Boolean
{{$NEXT}}
-
+ * Use String::Trim to provide a trim function
0.003 2010-10-31
* Require Perl 5.10.1 - RT#62574: Fails on perl 5.10.0
0.002 2010-10-25
View
@@ -9,6 +9,7 @@ package Lingua::Boolean;
use Carp;
use boolean 0.21 qw(true false);
+use String::Trim;
=head1 SYNOPSIS
@@ -144,7 +145,7 @@ sub _boolean {
my $self = shift;
my $to_test = shift;
my $lang = shift || 'en';
- _trim($to_test);
+ trim($to_test);
if ($self->_looks_true($to_test, $lang)) {
return true;
@@ -161,7 +162,7 @@ sub boolean {
my $self = ref $_[0] eq __PACKAGE__ ? shift : __PACKAGE__->new($_[1]);
my $to_test = shift;
my $lang = shift || $self->{lang};
- _trim($to_test);
+ trim($to_test);
return $self->_boolean($to_test, $lang);
}
@@ -226,7 +227,7 @@ sub _looks_true {
my $self = shift;
my $to_test = shift;
my $lang = shift || 'en';
- _trim($to_test);
+ trim($to_test);
croak "I don't know anything about the language '$lang'" unless exists $self->{languages}->{$lang}->{match}->{True};
return true if ($to_test ~~ $self->{languages}->{$lang}->{match}->{True});
@@ -237,20 +238,13 @@ sub _looks_false {
my $self = shift;
my $to_test = shift;
my $lang = shift || 'en';
- _trim($to_test);
+ trim($to_test);
croak "I don't know anything about the language '$lang'" unless exists $self->{languages}->{$lang}->{match}->{False};
return true if ($to_test ~~ $self->{languages}->{$lang}->{match}->{False});
return false;
}
-sub _trim { # http://www.perlmonks.org/?node_id=36684
- @_ = $_ if not @_ and defined wantarray;
- @_ = @_ if defined wantarray;
- for (@_ ? @_ : $_) { s/^\s+|\s+$//g }
- return wantarray ? @_ : $_[0] if defined wantarray;
-}
-
1;
__END__
View
@@ -20,7 +20,7 @@ my @should_have_names = (
subtest 'oo' => sub {
plan tests => 4;
my $bool = new_ok('Lingua::Boolean');
- can_ok($bool, qw(boolean langs languages _looks_true _looks_false _trim));
+ can_ok($bool, qw(boolean langs languages _looks_true _looks_false));
{ # Language codes
my @has = $bool->langs();
is_deeply(\@has, \@should_have_codes, 'Available language codes OK');

0 comments on commit 681bb09

Please sign in to comment.