Scalar::Compare - Dynamically use comparison operators
my $scalar1 = 'waffle'; my $scalar2 = 'pirate'; my $operator = 'ne'; if (scalar_compare($scalar1, $operator, $scalar2)) { warn "Proceed normally."; }
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.
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;
Bizowie <http://bizowie.com>
Copyright (C) 2013 Bizowie
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.