The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Switch::Perlish::Smatch::Comparators - Overall document for comparator behaviour.

COMPARATORS

Below is a complete listing of the default comparators that come with Switch::Perlish.

In each comparator description $t refers to the topic and $m refers to the match, or the first and second arguments, respectively.

Array

ARRAY

Smatch for an element of @$m in @$t.

CODE

Call &$m with @$t.

HASH

Check if an element of @$t exists as a key in %$m.

OBJECT

Check if an element of @$t exists as a method of $m.

Regexp

Match $m against the elements of @$t.

SCALAR

Check if $m points to an element of @$t.

UNDEF

Return false as $t is already defined.

VALUE

Smatch for $m in @$t.

Code

ARRAY

Check if $m refers to $t.

CODE

Pass %$m to $t.

HASH

Pass @$m to $t.

OBJECT

Pass $m to $t.

Regexp

Pass $m to $t.

SCALAR

Call $t with $m.

VALUE

Call $t with $m.

Hash

ARRAY

Check if an element of @$m exists as a key of %$t.

CODE

Check if the return from &$m is a hash key of %$t.

HASH

Check if a key => value pair exists in both %$t and %$m.

OBJECT

Check if a key of %$t exists as a method of $m.

Regexp

Check if any keys from %$t match $m.

SCALAR

Check if $m points to value in %$t.

UNDEF

Check for an undefined value in %$t (better suggestions welcome).

VALUE

Check if $m exists as a key in %$t.

Object

ARRAY

If the $t is a blessed ARRAY, delegate to the ARRAY<=>ARRAY comparator, otherwise returns false.

CODE

Call the $t on &$m i.e $t->$m.

HASH

If the $t is a blessed HASH, delegate to the HASH<=>HASH comparator, otherwise returns false.

OBJECT

Check if the $t->isa($m) or the same class (better suggestions welcome).

Regexp

Match the class of $t against the $m.

SCALAR

Check if the $m points to the $t.

UNDEF

croak("Can't compare OBJECT with an undef") # Suggestions welcome.

VALUE

Check if $t has $m as a method.

Regexp

ARRAY

Match $t for every element in @$m.

CODE

Pass $t to &$m.

HASH

Check if any of keys of %$m match $t.

OBJECT

Match $t against $m's class.

Regexp

Match $m to $t.

SCALAR

Check if $m refers to $t.

UNDEF

croak("Can't compare Regexp with an undef") # suggestions welcome.

VALUE

Match $t against $m.

Scalar

ARRAY

Check if $t points to an element of @$m.

CODE

Check if $t points to $m.

HASH

Check if $t points to value in %$m.

OBJECT

Check if $t refers to the object $m.

Regexp

Check if $t refers to the Regexp object $m.

SCALAR

Numerically compare the scalar refs $t and $m.

UNDEF

Check if $$t is undef.

VALUE

Call Switch::Perlish::Smatch::value_cmp() with $$t and $m.

Undef

ARRAY

Check for an undef in @$m.

CODE

Pass undef to &$m (to be consistent with other CODE comparators).

HASH

Check for an undefined value in %$m (better suggestions welcome).

OBJECT

croak("Can't compare undef with OBJECT") # Suggestions welcome.

Regexp

croak("Can't compare undef with Regexp") # Suggestions welcome.

SCALAR

Check if $$m is undef.

UNDEF

Return true as $m is also undefined.

VALUE

Return false as $m is already defined.

Value

ARRAY

Check if $t is in $m.

CODE

Pass $t to &$m.

HASH

Check if $t exists as a key in $m.

OBJECT

Check if the method $t exists in $m.

Regexp

Match $t against $m.

SCALAR

Check if what $$m is the same as $t.

UNDEF

Return false, a VALUE is always defined.

VALUE

Call Switch::Perlish::Smatch::value_cmp() with $t and $m.

SEE. ALSO

Switch::Perlish::Smatch

AUTHOR

Dan Brook <mr.daniel.brook@gmail.com>

COPYRIGHT

Copyright (c) 2006, Dan Brook. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.