Data-Math

 view release on metacpan or  search on metacpan

lib/Data/Math.pm  view on Meta::CPAN

        $result =  $s2;
      } elsif ( not( defined $s2 ) || $s2 eq '' ) {
        $result =  $s1;
      } else {
        $result = $s1 . $join_char. $s2;
      }
    } elsif ( $s1 eq $s2 ) {
      $result = $s1;
    }
  }
  elsif ( $policy eq 'pick_one') {

    if ( $s1 ne $s2 ) {
      if (  not( defined $s2 ) || $s2 eq '' ) {
        $result =  $s1;
      } elsif ( not( defined $s1 ) || $s1 eq '' ) {
        $result =  $s2;
      } else {
        $result = $s1; # favor the first if the second is different
      }
    } elsif ( $s1 eq $s2 ) {
      $result = $s1;
    }
  }

  elsif ( $policy eq 'pick_2nd') {
    if ( $s1 ne $s2 ) {
      if ( not( defined $s1 ) || $s1 eq '' ) {
        $result =  $s2;
      } elsif ( not( defined $s2 ) || $s2 eq '' ) {
        $result =  $s1;
      } else {
        $result = $s2; # favor the second if it differs from the first
      }
    } elsif ( $s1 eq $s2 ) {
      $result = $s2;
    }
  } else {
    carp "Data::Math: Unsupported string_policy: $policy";
  }
  return $result;
}

1;

# A Mouse/Moose performance tweak
__PACKAGE__->meta->make_immutable();

1;

=back

=head1 TODO

  o  look into 'preserve_source' options and such to
     improve memory efficiency

  o  try an operator overload interface

  o  examine possibility of arbitrary user-defineable
     operations (pattern/action callbacks?)

=head1 AUTHOR

Joseph Brenner, E<lt>doom@kzsu.stanford.eduE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2016 by Joseph Brenner

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

See http://dev.perl.org/licenses/ for more information.

=cut



( run in 1.741 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )