| 1 | package Farly::Transport::PortRange; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 17 | ▶ | use 5.008008; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 17 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | 17 | ▶ | use Farly::Transport::Port; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 17 | ▶ | use Farly::Transport::Object; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | 17 | our $VERSION = '0.26'; | |||||||||||||
| 11 | 17 | our @ISA = qw(Farly::Transport::Object); | |||||||||||||
| 12 | |||||||||||||||
| 13 | 112 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||
| 14 | 112 | my ( $class, $first, $last ) = @_; | |||||||||||||
| 15 | |||||||||||||||
| 16 | 112 | my $self = { | |||||||||||||
| 17 | LOW => undef, | ||||||||||||||
| 18 | HIGH => undef, | ||||||||||||||
| 19 | }; | ||||||||||||||
| 20 | 112 | bless( $self, $class ); | |||||||||||||
| 21 | |||||||||||||||
| 22 | 112 | ▶ | if ( defined $last ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 23 | 24 | $self->{LOW} = Farly::Transport::Port->new($first); | |||||||||||||
| 24 | 24 | $self->{HIGH} = Farly::Transport::Port->new($last); | |||||||||||||
| 25 | } | ||||||||||||||
| 26 | elsif ( defined $first ) { | ||||||||||||||
| 27 | 88 | my ( $low, $high ) = split( /-|\s+/, $first ); | |||||||||||||
| 28 | 88 | $self->{LOW} = Farly::Transport::Port->new($low); | |||||||||||||
| 29 | 88 | $self->{HIGH} = Farly::Transport::Port->new($high); | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 112 | ▶ | confess "invalid port range" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 33 | if ( $self->first() > $self->last() ); | ||||||||||||||
| 34 | |||||||||||||||
| 35 | 112 | return $self; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 17 | ▶ | sub low { | ||||||||||||
|
Subroutine
low: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 39 | 17 | return $_[0]->{LOW}; | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | |||||||||||||||
| 42 | 17 | ▶ | sub high { | ||||||||||||
|
Subroutine
high: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 43 | 17 | return $_[0]->{HIGH}; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 265 | ▶ | sub first { | ||||||||||||
|
Subroutine
first: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 47 | 265 | return $_[0]->{LOW}->port(); | |||||||||||||
| 48 | } | ||||||||||||||
| 49 | |||||||||||||||
| 50 | 182 | ▶ | sub last { | ||||||||||||
|
Subroutine
last: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 51 | 182 | return $_[0]->{HIGH}->port(); | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 17 | ▶ | sub as_string { | ||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 55 | 17 | my ($self) = @_; | |||||||||||||
| 56 | 17 | return join( " ", $self->low()->as_string(), $self->high()->as_string() ); | |||||||||||||
| 57 | } | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 0 | ▶ | sub iter { | ||||||||||||
|
Subroutine
iter: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 60 | 0 | my ($self) = @_; | |||||||||||||
| 61 | |||||||||||||||
| 62 | 0 | my @list; | |||||||||||||
| 63 | 0 | my $i = $self->first(); | |||||||||||||
| 64 | |||||||||||||||
| 65 | 0 | ▶ | do { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 66 | |||||||||||||||
| 67 | 0 | push @list, Farly::Transport::Port->new($i); | |||||||||||||
| 68 | 0 | $i++; | |||||||||||||
| 69 | |||||||||||||||
| 70 | } while ( $i < $self->last() ); | ||||||||||||||
| 71 | |||||||||||||||
| 72 | 0 | return @list; | |||||||||||||
| 73 | } | ||||||||||||||
| 74 | |||||||||||||||
| 75 | 17 | 1; | |||||||||||||
| 76 | __END__ | ||||||||||||||