Hub::Perl::Compare

- NAME
- SYNOPSIS
- DESCRIPTION
- METHODS
- INTERNAL
- AUTHOR
- COPYRIGHT
- UPDATED

# NAME

Hub::Perl::Compare -

Part of the Hub Library

Top

# SYNOPSIS

Top

# DESCRIPTION

Top

# METHODS

compare

compare
  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);

  This example returns: true:

          compare('eq','abc','abc');

  This example returns: true:

          compare('ne','abc','Abc');

  This example returns: false:

          compare('eq','abc',undef);

  This example returns: true:

          compare('!~','abc','A');

  This example returns: true:

          compare('=~','abc','a');

  This example returns: true:

          compare('==',1234,1234);

  This example returns: true:

          compare('>=',1234,1234);

  This example returns: true:

          compare('eqic','abc','Abc');

  This example returns: true:

          compare('==',undef,undef);

  This example returns: true:

          compare('==',0,undef);

  Example: This example:

          my @numbers = ( 20, 1, 10, 2 );
                    join ';', sort { &compare('<=>',$a,$b) } @numbers;

  matches:

          1;2;10;20

Top

# INTERNAL

Top

# AUTHOR

Ryan Gies

Top

# COPYRIGHT

Copyright (c) 2006 Livesite Networks, LLC. All rights reserved.

Copyright (c) 2000-2005 Ryan Gies. All rights reserved.

Top

# UPDATED

This file created by on at

Top