| 1 | package Switch::Perlish::Smatch::Scalar; | ||||||||||
| 2 | |||||||||||
| 3 | 11 | $VERSION = '1.0.0'; | |||||||||
| 4 | |||||||||||
| 5 | 11 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 11 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 11 | ▶ | use Switch::Perlish::Smatch 'value_cmp'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | ## DESC - Call C<Switch::Perlish::Smatch::value_cmp()> with $$t and $m. | ||||||||||
| 11 | 2 | ▶ | sub _VALUE { | ||||||||
|
Subroutine
_VALUE: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | my($t, $m) = @_; | |||||||||
| 13 | 2 | return value_cmp($$t, $m); | |||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | ## DESC - Check if $$t is undef. | ||||||||||
| 17 | 1 | ▶ | sub _UNDEF { | ||||||||
|
Subroutine
_UNDEF: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | my($t, $m) = @_; | |||||||||
| 19 | 1 | return !defined($$t); | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | ## DESC - Numerically compare the scalar refs. | ||||||||||
| 23 | 5 | ▶ | sub _SCALAR { | ||||||||
|
Subroutine
_SCALAR: called CC=1 SCAR=0.0
| |||||||||||
| 24 | 5 | my($t, $m) = @_; | |||||||||
| 25 | 5 | return $t == $m; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | ## Not sure if this is the right thing to do. | ||||||||||
| 29 | ## DESC - Check if $t points to an element of @$m. | ||||||||||
| 30 | 2 | ▶ | sub _ARRAY { | ||||||||
|
Subroutine
_ARRAY: called CC=3 SCAR=11.0
| |||||||||||
| 31 | 2 | my($t, $m) = @_; | |||||||||
| 32 | \$_ == $t and return 1 | ||||||||||
| 33 | 2 | ▶ | for @$m; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 1 | return; | |||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | ## This is an awkward comparator. | ||||||||||
| 38 | ## DESC - Check if $t points to a value in %$m. | ||||||||||
| 39 | 2 | ▶ | sub _HASH { | ||||||||
|
Subroutine
_HASH: called CC=3 SCAR=11.0
| |||||||||||
| 40 | 2 | my($t, $m) = @_; | |||||||||
| 41 | \$_ == $t and return 1 | ||||||||||
| 42 | 2 | ▶ | for values %$m; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 1 | return; | |||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | ## DESC - Check if $t points to $m. | ||||||||||
| 47 | 1 | ▶ | sub _CODE { | ||||||||
|
Subroutine
_CODE: called CC=1 SCAR=0.0
| |||||||||||
| 48 | 1 | my($t, $m) = @_; | |||||||||
| 49 | 1 | return $t == \$m; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | ## Another awkward comparator. | ||||||||||
| 53 | ## DESC - Check if the sref refers to the object. | ||||||||||
| 54 | 3 | ▶ | sub _OBJECT { | ||||||||
|
Subroutine
_OBJECT: called CC=1 SCAR=0.0
| |||||||||||
| 55 | 3 | my($t, $m) = @_; | |||||||||
| 56 | 3 | return $$t == $m; | |||||||||
| 57 | } | ||||||||||
| 58 | |||||||||||
| 59 | ## Comparing scalar refs with other things doesn't feel right. | ||||||||||
| 60 | ## DESC - Check if the sref refers to the Regexp object. | ||||||||||
| 61 | 0 | ▶ | sub _Regexp { | ||||||||
|
Subroutine
_Regexp: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | 0 | my($t, $m) = @_; | |||||||||
| 63 | 0 | return $$t == $m; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 11 | Switch::Perlish::Smatch->register_package( __PACKAGE__, 'SCALAR' ); | |||||||||
| 67 | |||||||||||
| 68 | 11 | 1; | |||||||||
| 69 | |||||||||||
| 70 | =pod | ||||||||||
| 71 | |||||||||||
| 72 | =head1 NAME | ||||||||||
| 73 | |||||||||||
| 74 | Switch::Perlish::Smatch::Scalar - The C<SCALAR> comparatory category package. | ||||||||||
| 75 | |||||||||||
| 76 | =head1 VERSION | ||||||||||
| 77 | |||||||||||
| 78 | 1.0.0 - Initial release. | ||||||||||
| 79 | |||||||||||
| 80 | =head1 DESCRIPTION | ||||||||||
| 81 | |||||||||||
| 82 | This package provides the default implementation for the C<SCALAR> comparator | ||||||||||
| 83 | category. For more information on the comparator implementation see. | ||||||||||
| 84 | L<Switch::Perlish::Smatch::Comparators/"Scalar">. | ||||||||||
| 85 | |||||||||||
| 86 | =head1 SEE. ALSO | ||||||||||
| 87 | |||||||||||
| 88 | L<Switch::Perlish::Smatch>. | ||||||||||
| 89 | |||||||||||
| 90 | =head1 AUTHOR | ||||||||||
| 91 | |||||||||||
| 92 | Dan Brook C<< <mr.daniel.brook@gmail.com> >> | ||||||||||
| 93 | |||||||||||
| 94 | =head1 COPYRIGHT | ||||||||||
| 95 | |||||||||||
| 96 | Copyright (c) 2006, Dan Brook. All Rights Reserved. This module is free | ||||||||||
| 97 | software. It may be used, redistributed and/or modified under the same | ||||||||||
| 98 | |||||||||||
| 99 | =cut | ||||||||||