| 1 | package POE::Component::Server::Bayeux::Utilities; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | our %EXPORT_TAGS = ( all => [qw(channel_match)] ); | |||||||||||||||||||||||||||
| 8 | 4 | our @EXPORT_OK = qw(channel_match); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 10 | ▶ | sub channel_match { | ||||||||||||||||||||||||||
|
Subroutine
channel_match: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 10 | my ($from, $to) = @_; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # Should channel $from be delivered to someone subscribed to channel $to? | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 10 | ▶ | return 1 if $from eq $to; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 9 | my @from = split /\//, $from; | |||||||||||||||||||||||||||
| 18 | 9 | my @to = split /\//, $to; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 9 | ▶ | for (my $i = 0; $i <= $#from; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 23 | ▶ | return 0 if ! defined $to[$i]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # Match all | ||||||||||||||||||||||||||||
| 24 | 22 | ▶ | return 1 if $to[$i] eq '**'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # If simple glob '*' and from has no more parts | ||||||||||||||||||||||||||||
| 27 | 21 | ▶ | return 1 if $to[$i] eq '*' && $#from == $i; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$to[$i] eq "*" and $#from == $i
MC/DC100%2/2
$to[$i] eq "*" and $#from == $i
$to[$i] eq "*"
$#from == $i
Truth table100%3/3
A and B
A= $to[$i] eq "*"B= $#from == $i
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 19 | ▶ | return 0 if $from[$i] ne $to[$i]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | return 0 if int @to > int @from; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | # If here, it matched | ||||||||||||||||||||||||||||
| 35 | 0 | return 1; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | 1; | |||||||||||||||||||||||||||