Michael Aquilina > Scalar-Compare-0.01 > Scalar::Compare

Download:
Scalar-Compare-0.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Scalar::Compare - Dynamically use comparison operators

SYNOPSIS ^

  my $scalar1  = 'waffle';
  my $scalar2  = 'pirate';
  my $operator = 'ne';
  if (scalar_compare($scalar1, $operator, $scalar2)) {
      warn "Proceed normally.";
  }

DESCRIPTION ^

Simple syntax sugar around Perl's comparison operators that allows you to arbitrarily compare scalars using Perl's comparison operators.

This is useful, for instance, if you want to support arbitrary comparison criteria in your application without lines and lines of if/else blocks.

FUNCTIONS ^

scalar_compare

Given a scalar, an operator, and another scalar, returns the result of that operator on the provided values.

For instance:

  my $ret = scalar_compare($s1, '==', $s2)

is equivalent to:

  my $ret = $s1 == $s2;

AUTHORS ^

Bizowie <http://bizowie.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2013 Bizowie

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

syntax highlighting: