| 1 | 1 | ▶ | use NetAddr::IP::Lite; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | my $nets = { | |||||||||||||
| 4 | '10.0.0.16' => [ 24, '10.0.0.1', '10.0.0.254', '10.0.0.11'], | ||||||||||||||
| 5 | '10.0.0.5' => [ 30, '10.0.0.5', '10.0.0.6', 'undef' ], | ||||||||||||||
| 6 | '10.128.0.1' => [ 8, '10.0.0.1', '10.255.255.254', '10.0.0.11'], | ||||||||||||||
| 7 | '10.128.0.1' => [ 24, '10.128.0.1', '10.128.0.254', '10.128.0.11'], | ||||||||||||||
| 8 | }; | ||||||||||||||
| 9 | |||||||||||||||
| 10 | 1 | $| = 1; | |||||||||||||
| 11 | 1 | print "1..", (3 * scalar keys %$nets), "\n"; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | my $count = 1; | |||||||||||||
| 14 | |||||||||||||||
| 15 | 1 | for my $a (keys %$nets) { | |||||||||||||
| 16 | 3 | my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; | |||||||||||||
| 17 | 3 | ▶ | print '', (($ip->first->addr ne $nets->{$a}->[1] ? | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 18 | 'not ' : ''), | ||||||||||||||
| 19 | "ok ", $count++, "\n"); | ||||||||||||||
| 20 | 3 | ▶ | print '', (($ip->last->addr ne $nets->{$a}->[2] ? | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 21 | 'not ' : ''), | ||||||||||||||
| 22 | "ok ", $count++, "\n"); | ||||||||||||||
| 23 | |||||||||||||||
| 24 | 3 | my $new = $ip->nth(10); | |||||||||||||
| 25 | 3 | ▶ | print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ? | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 26 | 'not ' : ''), | ||||||||||||||
| 27 | "ok ", $count++, "\n"); | ||||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | |||||||||||||||