Hub::Perl::Compare -
Part of the Hub Library
Wrapper for Perl's internal comparison operators.
Usage: compare OPERATOR, LEFT_OPERAND, RIGHT_OPERAND
OPERATOR's:
eq ne lt le gt ge == != < > <= >=
Extended OPERATOR's:
eqic Equal ignore case neic Not-equal ignore case
The purpose here is twofold: a) support runtime comparison when the operator is held as string; and b) behave like Perl does when warnings are disabled.
This example returns: true:
compare('eq','',undef);
compare('eq','abc','abc');
compare('ne','abc','Abc');
This example returns: false:
compare('eq','abc',undef);
compare('!~','abc','A');
compare('=~','abc','a');
compare('==',1234,1234);
compare('>=',1234,1234);
compare('eqic','abc','Abc');
compare('==',undef,undef);
compare('==',0,undef);
Example: This example:
my @numbers = ( 20, 1, 10, 2 ); join ';', sort { &compare('<=>',$a,$b) } @numbers;
matches:
1;2;10;20
Ryan Gies
Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.
Copyright (c) 2000-2005 Ryan Gies. All rights reserved.
This file created by on at
To install Hub, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Hub
CPAN shell
perl -MCPAN -e shell install Hub
For more information on module installation, please visit the detailed CPAN module installation guide.