| 1 | package Net::SDP::Time; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | ################ | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Net::SDP - Session Description Protocol (rfc2327) | ||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # Nicholas J Humfrey | ||||||||||||||||||||||||||||
| 8 | # njh@cpan.org | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | # See the bottom of this file for the POD documentation. | ||||||||||||||||||||||||||||
| 11 | # | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 5 | ▶ | use vars qw/$VERSION/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 5 | ▶ | use constant NTPOFFSET => 2208988800; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 5 | $VERSION="0.07"; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 4 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 24 | 4 | my $self = { | |||||||||||||||||||||||||||
| 25 | 't_start' => '0', | ||||||||||||||||||||||||||||
| 26 | 't_end' => '0', | ||||||||||||||||||||||||||||
| 27 | 'r' => [], | ||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||
| 29 | 4 | bless $self, $class; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # Initial value provided ? | ||||||||||||||||||||||||||||
| 32 | 4 | my ($t) = @_; | |||||||||||||||||||||||||||
| 33 | 4 | ▶ | $self->_parse_t($t) if (defined $t); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | return $self; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 8 | ▶ | sub _ntptime { | ||||||||||||||||||||||||||
|
Subroutine
_ntptime: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 8 | return time() + NTPOFFSET; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | #sub remove { | ||||||||||||||||||||||||||||
| 43 | # my $self=shift; | ||||||||||||||||||||||||||||
| 44 | # | ||||||||||||||||||||||||||||
| 45 | # ### Delete ourselves from our parent's array | ||||||||||||||||||||||||||||
| 46 | # | ||||||||||||||||||||||||||||
| 47 | # undef $self; | ||||||||||||||||||||||||||||
| 48 | #} | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub _parse_t { | ||||||||||||||||||||||||||
|
Subroutine
_parse_t: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 52 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 53 | 1 | my ($t) = @_; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # we need two positive integers | ||||||||||||||||||||||||||||
| 56 | # t=<start-time> <end-time> | ||||||||||||||||||||||||||||
| 57 | 1 | ▶ | if ( $t !~ /^([0-9]+) ([0-9]+)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | warn "Invalid 't' passed: $t"; | |||||||||||||||||||||||||||
| 59 | 0 | return 0; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | ($self->{'t_start'}, $self->{'t_end'}) = split(/ /, $t); | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # Success | ||||||||||||||||||||||||||||
| 65 | 1 | return 1; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 1 | ▶ | sub _generate_t { | ||||||||||||||||||||||||||
|
Subroutine
_generate_t: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 1 | return "t=".$self->{'t_start'}.' '.$self->{'t_end'}."\n"; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub _parse_r { | ||||||||||||||||||||||||||
|
Subroutine
_parse_r: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 76 | 0 | my ($r) = @_; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( $self->is_permanent ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | warn "corrupt packet, you cannot have a repeat field for a permanent session"; | |||||||||||||||||||||||||||
| 80 | 0 | return 0; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # we need at least three | ||||||||||||||||||||||||||||
| 84 | # r=<repeat-interval> <active duration> <offsets from start-time> | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if ( $r !~ /^([0-9]+[dhms]?)( [0-9]+[dhms]?){2,}$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | warn "Invalid 'r' passed: $r"; | |||||||||||||||||||||||||||
| 87 | 0 | return 0; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | my @values = split / /, $r; | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ( $values[0] == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 0 | warn "you cannot have a repeat interval of zero"; | |||||||||||||||||||||||||||
| 93 | 0 | return 0; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | _repeat_push($self, \@values); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # Success | ||||||||||||||||||||||||||||
| 99 | 0 | return 1; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 2 | ▶ | sub _generate_r { | ||||||||||||||||||||||||||
|
Subroutine
_generate_r: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 103 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | my $result = ''; | |||||||||||||||||||||||||||
| 106 | 2 | foreach my $item ( @{$self->{'r'}} ) | |||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||
| 108 | my $element = _rollup_seconds($item->{'interval'}) . ' ' | ||||||||||||||||||||||||||||
| 109 | 2 | . _rollup_seconds($item->{'duration'}); | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 2 | foreach my $offset ( @{$item->{'offsets'}} ) { | |||||||||||||||||||||||||||
| 112 | 3 | $element .= ' ' . _rollup_seconds( $offset ); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 2 | $result .= 'r=' . $element . "\n"; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 2 | return $result; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 48 | ▶ | sub start_time_ntp { | ||||||||||||||||||||||||||
|
Subroutine
start_time_ntp: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 48 | my $self=shift; | |||||||||||||||||||||||||||
| 124 | 48 | my ($start_time) = @_; | |||||||||||||||||||||||||||
| 125 | 48 | ▶ | if ( defined $start_time ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 3 | $self->{'t_start'} = $start_time; | |||||||||||||||||||||||||||
| 127 | # you cannot have a permanent session with repeat interval | ||||||||||||||||||||||||||||
| 128 | 3 | ▶ | $self->repeat_delete_all if ( $start_time == 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | 48 | return $self->{'t_start'}; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 18 | ▶ | sub end_time_ntp { | ||||||||||||||||||||||||||
|
Subroutine
end_time_ntp: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 134 | 18 | my $self=shift; | |||||||||||||||||||||||||||
| 135 | 18 | my ($end_time) = @_; | |||||||||||||||||||||||||||
| 136 | 18 | ▶ | $self->{'t_end'} = $end_time if defined $end_time; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 18 | return $self->{'t_end'}; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 13 | ▶ | sub start_time_unix { | ||||||||||||||||||||||||||
|
Subroutine
start_time_unix: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 141 | 13 | my $self=shift; | |||||||||||||||||||||||||||
| 142 | 13 | my ($start_time) = @_; | |||||||||||||||||||||||||||
| 143 | 13 | ▶ | $self->start_time_ntp( $start_time+NTPOFFSET ) if (defined $start_time); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 144 | 13 | ▶ | return 0 if ($self->start_time_ntp()==0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 13 | return $self->start_time_ntp() - NTPOFFSET; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 5 | ▶ | sub end_time_unix { | ||||||||||||||||||||||||||
|
Subroutine
end_time_unix: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 149 | 5 | my $self=shift; | |||||||||||||||||||||||||||
| 150 | 5 | my ($end_time) = @_; | |||||||||||||||||||||||||||
| 151 | 5 | ▶ | $self->end_time_ntp( $end_time+NTPOFFSET ) if (defined $end_time); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 5 | ▶ | return 0 if ($self->end_time_ntp()==0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 5 | return $self->end_time_ntp() - NTPOFFSET; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 4 | ▶ | sub start_time { | ||||||||||||||||||||||||||
|
Subroutine
start_time: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 157 | 4 | my $self=shift; | |||||||||||||||||||||||||||
| 158 | 4 | ▶ | return "Permanent" if ($self->is_permanent()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 4 | return scalar(localtime($self->start_time_unix())) | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 3 | ▶ | sub end_time { | ||||||||||||||||||||||||||
|
Subroutine
end_time: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 163 | 3 | my $self=shift; | |||||||||||||||||||||||||||
| 164 | 3 | ▶ | return "Permanent" if ($self->is_permanent()); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | 3 | ▶ | return "Unbounded" if ($self->end_time_ntp()==0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | 2 | return scalar(localtime($self->end_time_unix())) | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 17 | ▶ | sub is_permanent { | ||||||||||||||||||||||||||
|
Subroutine
is_permanent: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 170 | 17 | my $self=shift; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 17 | ▶ | if ($self->start_time_ntp()==0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 2 | { return 1; } | |||||||||||||||||||||||||||
| 174 | 15 | else { return 0; } | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 2 | ▶ | sub make_permanent { | ||||||||||||||||||||||||||
|
Subroutine
make_permanent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 2 | my $self=shift; | |||||||||||||||||||||||||||
| 179 | 2 | $self->{'t_start'} = 0; | |||||||||||||||||||||||||||
| 180 | 2 | $self->{'t_end'} = 0; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | # you cannot have a permanent session with repeat intervals | ||||||||||||||||||||||||||||
| 183 | 2 | $self->repeat_delete_all; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub is_unbounded { | ||||||||||||||||||||||||||
|
Subroutine
is_unbounded: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 187 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ($self->end_time_ntp()==0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | { return 1; } | |||||||||||||||||||||||||||
| 191 | 0 | else { return 0; } | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 2 | ▶ | sub make_unbounded { | ||||||||||||||||||||||||||
|
Subroutine
make_unbounded: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | 2 | my $self=shift; | |||||||||||||||||||||||||||
| 196 | 2 | $self->{'t_end'} = 0; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | # you cannot have a permanent session with repeat intervals | ||||||||||||||||||||||||||||
| 199 | 2 | $self->repeat_delete_all(); | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 5 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=20 SCAR=35.2
Pod
documented
| |||||||||||||||||||||||||||||
| 203 | 5 | my $self=shift; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | # Permanent | ||||||||||||||||||||||||||||
| 206 | 5 | ▶ | if ( $self->is_permanent() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 1 | return "Broadcasts permanently."; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | # Repeat elements present | ||||||||||||||||||||||||||||
| 212 | 4 | ▶ | if ( @{$self->{'r'}} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 213 | 2 | my $text; | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 2 | ▶ | if ( $self->end_time_ntp() == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | 1 | $text = 'Broadcasts '; | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||
| 219 | 1 | $text = 'Until ' . $self->end_time() . ', broadcasts '; | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 2 | my @repeatSlots = (); | |||||||||||||||||||||||||||
| 223 | 2 | foreach my $repeat ( @{$self->{'r'}} ) { | |||||||||||||||||||||||||||
| 224 | 3 | my $interval = _summariseTime($repeat->{interval}); | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 3 | my %results = ( | |||||||||||||||||||||||||||
| 227 | interval => $interval, | ||||||||||||||||||||||||||||
| 228 | times => [ ] | ||||||||||||||||||||||||||||
| 229 | ); | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 3 | my @abbr = qw( Sun Mon Tue Wed Thu Fri Sat ); | |||||||||||||||||||||||||||
| 232 | # the results output depends on the interval | ||||||||||||||||||||||||||||
| 233 | 3 | foreach my $offset ( @{$repeat->{offsets}} ) { | |||||||||||||||||||||||||||
| 234 | 3 | my @startTime = localtime($self->start_time_unix() + $offset); | |||||||||||||||||||||||||||
| 235 | 3 | my @endTime = localtime($self->start_time_unix() + $offset + $repeat->{duration} ); | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 3 | my $time; | |||||||||||||||||||||||||||
| 238 | # weekly: display which day | ||||||||||||||||||||||||||||
| 239 | 3 | ▶ | if ( $repeat->{interval} == 604800 ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 240 | 0 | $time = 'every ' . $abbr[$startTime[6]] . ', from '; | |||||||||||||||||||||||||||
| 241 | 0 | $time .= _buildHourlyTime(\@startTime, \@endTime); | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | # daily: display which hour | ||||||||||||||||||||||||||||
| 244 | elsif ( $repeat->{interval} == 86400 ) { | ||||||||||||||||||||||||||||
| 245 | 0 | $time = _buildHourlyTime(\@startTime, \@endTime); | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | # hourly: display minutely times | ||||||||||||||||||||||||||||
| 248 | elsif ( $repeat->{interval} == 3600 ) { | ||||||||||||||||||||||||||||
| 249 | 3 | $time = 'from ' . $startTime[1] . 'mins until ' . $endTime[1] . 'mins past'; | |||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | # we fall back to the best we can do which is a more direct | ||||||||||||||||||||||||||||
| 252 | # textual description of the 'r' field | ||||||||||||||||||||||||||||
| 253 | # anyone being caught here might want to consider improving | ||||||||||||||||||||||||||||
| 254 | # the above common cases and/or adding their common cases | ||||||||||||||||||||||||||||
| 255 | # that I could not think of | ||||||||||||||||||||||||||||
| 256 | else { | ||||||||||||||||||||||||||||
| 257 | 0 | my $friendlierOffset = _rollup_seconds($offset); | |||||||||||||||||||||||||||
| 258 | 0 | ▶ | $friendlierOffset .= 's' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | if ( $friendlierOffset =~ /^[0-9]+$/ ); | ||||||||||||||||||||||||||||
| 260 | 0 | my $friendlierDuration = _rollup_seconds($repeat->{duration}); | |||||||||||||||||||||||||||
| 261 | 0 | ▶ | $friendlierDuration .= 's' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | if ( $friendlierDuration =~ /^[0-9]+$/ ); | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | $time = " starting $friendlierOffset past the interval and lasting $friendlierDuration"; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 3 | push @{$results{times}}, $time; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 3 | push @repeatSlots, \%results; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 2 | ▶ | while ( my $repeater = shift @repeatSlots ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | 3 | ▶ | if ( $repeater->{interval} !~ /^[0-9]+$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 3 | $text .= 'every ' . $repeater->{interval} . ' '; | |||||||||||||||||||||||||||
| 276 | } else { | ||||||||||||||||||||||||||||
| 277 | 0 | my $friendlierInterval = _rollup_seconds($repeater->{interval}); | |||||||||||||||||||||||||||
| 278 | 0 | ▶ | $friendlierInterval .= 's' if ( $friendlierInterval =~ /^[0-9]+$/ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 0 | $text .= "every $friendlierInterval interval "; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 3 | ▶ | while ( my $repeaterTimes = shift @{$repeater->{times}} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | 3 | $text .= $repeaterTimes; | |||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 3 | ▶ | if ( scalar(@{$repeater->{times}}) > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 286 | 0 | $text .= ', '; | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | 3 | elsif ( scalar(@{$repeater->{times}}) == 1 ) { | |||||||||||||||||||||||||||
| 289 | 0 | $text .= ' and '; | |||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 3 | ▶ | if ( scalar(@repeatSlots) > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 294 | 0 | $text .= ', again'; | |||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||
| 296 | elsif ( scalar(@repeatSlots) == 1 ) { | ||||||||||||||||||||||||||||
| 297 | 1 | $text .= ', and again '; | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 2 | $text .= ' starting ' . $self->start_time() . '.'; | |||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 2 | return $text; | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | # no repeat elements so nice and simple | ||||||||||||||||||||||||||||
| 307 | else { | ||||||||||||||||||||||||||||
| 308 | 2 | ▶ | if ( $self->start_time_ntp() == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 0 | return 'Broadcasts until ' . $self->end_time().'.' ; | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | else { | ||||||||||||||||||||||||||||
| 312 | 2 | return 'Broadcasts from ' . $self->start_time() . ' until ' . $self->end_time().'.' ; | |||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub _buildHourlyTime { | ||||||||||||||||||||||||||
|
Subroutine
_buildHourlyTime: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 318 | 0 | my $startTime = shift; | |||||||||||||||||||||||||||
| 319 | 0 | my $endTime = shift; | |||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | 0 | my @times = ( $startTime->[2], $startTime->[1], $endTime->[2], $endTime->[1] ); | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 0 | foreach my $item ( 0..(scalar(@times) - 1 ) ) { | |||||||||||||||||||||||||||
| 324 | 0 | ▶ | $times[$item] = ( length($times[$item]) == 1 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | ? '0' . $times[$item] | ||||||||||||||||||||||||||||
| 326 | : $times[$item]; | ||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | return $times[0] . ':' . $times[1] . ' until ' . $times[2] . ':' . $times[3]; | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 3 | ▶ | sub _summariseTime { | ||||||||||||||||||||||||||
|
Subroutine
_summariseTime: called CC=10 SCAR=37.9
| |||||||||||||||||||||||||||||
| 333 | 3 | my $value = shift; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | # we can only do from minutes to weeks as after that how many | ||||||||||||||||||||||||||||
| 336 | # days are there in a month, what about a year, etc etc? | ||||||||||||||||||||||||||||
| 337 | 3 | ▶ | if ( ( $value % 604800 ) == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 338 | 0 | $value /= 604800; | |||||||||||||||||||||||||||
| 339 | 0 | ▶ | $value = ( $value == 1 ) ? 'week' : $value . ' weeks'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | elsif ( ( $value % 86400 ) == 0 ) { | ||||||||||||||||||||||||||||
| 342 | 0 | $value /= 86400; | |||||||||||||||||||||||||||
| 343 | 0 | ▶ | $value = ( $value == 1 ) ? 'day' : $value . ' days'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | elsif ( ( $value % 3600 ) == 0 ) { | ||||||||||||||||||||||||||||
| 346 | 3 | $value /= 3600; | |||||||||||||||||||||||||||
| 347 | 3 | ▶ | $value = ( $value == 1 ) ? 'hour' : $value . ' hours'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | elsif ( ( $value % 60 ) == 0 ) { | ||||||||||||||||||||||||||||
| 350 | 0 | $value /= 60; | |||||||||||||||||||||||||||
| 351 | 0 | ▶ | $value = ( $value == 1 ) ? 'minute' : $value . ' minutes'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||
| 354 | 0 | ▶ | $value = ( $value == 1 ) ? 'second' : $value . ' seconds'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 3 | return $value; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 4 | ▶ | sub repeat_add { | ||||||||||||||||||||||||||
|
Subroutine
repeat_add: called CC=8 SCAR=22.5
Pod
documented
| |||||||||||||||||||||||||||||
| 361 | 4 | my $self=shift; | |||||||||||||||||||||||||||
| 362 | 4 | my ($interval, $duration, $offsets) = @_; | |||||||||||||||||||||||||||
| 363 | 4 | ▶ | carp "Missing interval parameter" unless (defined $interval); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 364 | 4 | ▶ | carp "Missing duration parameter" unless (defined $duration); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 365 | 4 | ▶ | carp "Missing offsets parameter" unless (defined $offsets); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | 4 | ▶ | carp "Interval parameter cannot be zero" if ( $interval =~ /^\d+$/ and $interval == 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$interval =~ /^\d+$/ and $interval == 0
MC/DC0%0/2
$interval =~ /^\d+$/ and $interval == 0
$interval =~ /^\d+$/
$interval == 0
Truth table66%2/3
A and B
A= $interval =~ /^\d+$/B= $interval == 0
| |||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 4 | ▶ | if ( $self->is_permanent ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | 0 | carp "repeat_add failed, you cannot have a repeat field for a permanent session"; | |||||||||||||||||||||||||||
| 370 | 0 | return; | |||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | # Make it is hashref if only one offset passed | ||||||||||||||||||||||||||||
| 374 | 4 | ▶ | $offsets = [ $offsets ] if ( ref($offsets) ne 'ARRAY' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 4 | my @values = ( $interval, $duration, ( @$offsets ) ); | |||||||||||||||||||||||||||
| 377 | 4 | _repeat_push($self, \@values); | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 4 | return $self->{'r'}->[-1]; | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 1 | ▶ | sub repeat_delete { | ||||||||||||||||||||||||||
|
Subroutine
repeat_delete: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||
| 383 | 1 | my $self=shift; | |||||||||||||||||||||||||||
| 384 | 1 | my ($num) = @_; | |||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 1 | ▶ | return 1 if ( !defined($num) || !defined($self->{'r'}->[$num]) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $num and defined $self->{"r"}[$num]
MC/DC0%0/2
defined $num and defined $self->{"r"}[$num]
defined $num
defined $self->{"r"}[$num]
Truth table33%1/3
A and B
A= defined $numB= defined $self->{"r"}[$num]
| |||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 1 | my $results = [ ]; | |||||||||||||||||||||||||||
| 389 | 1 | for my $loop ( 0...(scalar(@{$self->{'r'}}) - 1) ) { | |||||||||||||||||||||||||||
| 390 | 2 | ▶ | next if ( $loop == $num ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 1 | push @$results, $self->{'r'}->[$loop]; | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | 1 | $self->{'r'} = $results; | |||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 1 | return 0; | |||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 5 | ▶ | sub repeat_delete_all { | ||||||||||||||||||||||||||
|
Subroutine
repeat_delete_all: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 400 | 5 | my $self=shift; | |||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 5 | $self->{'r'} = [ ]; | |||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | 5 | return 0; | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 1 | ▶ | sub repeat_desc { | ||||||||||||||||||||||||||
|
Subroutine
repeat_desc: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 408 | 1 | my $self=shift; | |||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 1 | my $num = shift; | |||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 1 | ▶ | $num = 0 if ( !defined($num) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 1 | ▶ | return undef if ( !defined($self->{'r'}->[$num]) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 1 | return $self->{'r'}->[$num]; | |||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 4 | ▶ | sub repeat_desc_arrayref { | ||||||||||||||||||||||||||
|
Subroutine
repeat_desc_arrayref: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 420 | 4 | my $self=shift; | |||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | 4 | ▶ | if ( defined($self->{'r'}) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | 4 | return $self->{'r'}; | |||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||
| 425 | 0 | return undef; | |||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 7 | ▶ | sub _rollup_seconds { | ||||||||||||||||||||||||||
|
Subroutine
_rollup_seconds: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||
| 429 | 7 | my $value = shift; | |||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 7 | ▶ | if ( $value !~ /^[0-9]+[dhms]?$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 0 | carp "Invalid value parsed to _rollup_seconds: $value"; | |||||||||||||||||||||||||||
| 433 | 0 | return; | |||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | # if its already partially rolled up we should unroll it all first | ||||||||||||||||||||||||||||
| 437 | 7 | ▶ | $value = _rollout_seconds($value) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 438 | if ( $value !~ /^[0-9]+[dhms]$/ ); | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | # if its zero do nothing with it | ||||||||||||||||||||||||||||
| 441 | 7 | ▶ | return 0 if ( $value == 0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | # try reducing to days | ||||||||||||||||||||||||||||
| 444 | 6 | ▶ | if ( ( $value % 86400 ) == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 445 | 1 | $value = ( $value / 86400 ) . 'd'; | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | # try reducing to hours | ||||||||||||||||||||||||||||
| 448 | elsif ( ( $value % 3600 ) == 0 ) { | ||||||||||||||||||||||||||||
| 449 | 3 | $value = ( $value / 3600 ) . 'h'; | |||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | # and finally try to minutes | ||||||||||||||||||||||||||||
| 452 | elsif ( ( $value % 60 ) == 0 ) { | ||||||||||||||||||||||||||||
| 453 | 2 | $value = ( $value / 60 ) . 'm'; | |||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 6 | return $value; | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | 20 | ▶ | sub _rollout_seconds { | ||||||||||||||||||||||||||
|
Subroutine
_rollout_seconds: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 460 | 20 | my $value = shift; | |||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | 20 | ▶ | if ( $value !~ /^[0-9]+[dhms]?$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 463 | 0 | carp "Invalid value parsed to _rollout_seconds: $value"; | |||||||||||||||||||||||||||
| 464 | 0 | return; | |||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | # test for a NOOP | ||||||||||||||||||||||||||||
| 468 | 20 | ▶ | if ( $value =~ /^[0-9]+s?$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | 17 | ▶ | $value = substr($value, 0, -1) if ( substr($value, -1, 1) eq 's' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | 17 | return int($value); | |||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 3 | my $unit = substr($value, -1, 1); | |||||||||||||||||||||||||||
| 474 | 3 | $value = substr($value, 0, -1); | |||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||
| 476 | 3 | ▶ | if ( $unit eq 'd' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 477 | 1 | $value *= 86400; | |||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | elsif ( $unit eq 'h' ) { | ||||||||||||||||||||||||||||
| 480 | 1 | $value *= 3600; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | # must be 'm' (minutes) | ||||||||||||||||||||||||||||
| 483 | else { | ||||||||||||||||||||||||||||
| 484 | 1 | $value *= 60; | |||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | 3 | return int($value); | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | 4 | ▶ | sub _repeat_push { | ||||||||||||||||||||||||||
|
Subroutine
_repeat_push: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 491 | 4 | my $self=shift; | |||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 4 | my $values = shift; | |||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | 4 | foreach my $item ( 0...(scalar(@$values) - 1) ) { | |||||||||||||||||||||||||||
| 496 | 13 | $values->[$item] = _rollout_seconds($values->[$item]); | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 4 | my $rProcessed = { | |||||||||||||||||||||||||||
| 500 | interval => shift @$values, | ||||||||||||||||||||||||||||
| 501 | duration => shift @$values, | ||||||||||||||||||||||||||||
| 502 | offsets => [ ] | ||||||||||||||||||||||||||||
| 503 | }; | ||||||||||||||||||||||||||||
| 504 | 4 | foreach my $offset ( @$values ) { | |||||||||||||||||||||||||||
| 505 | 5 | push @{$rProcessed->{'offsets'}}, $offset; | |||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 4 | push @{$self->{'r'}}, $rProcessed; | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 5 | 1; | |||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | __END__ | ||||||||||||||||||||||||||||