equal
deleted
inserted
replaced
15 |
15 |
16 |
16 |
17 # the sort order for the records of the same label |
17 # the sort order for the records of the same label |
18 my %ORDER = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA SSHFP); |
18 my %ORDER = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA SSHFP); |
19 |
19 |
|
20 # input $arg - hash with options |
|
21 # $data - a long string with the zone data |
20 sub parse { |
22 sub parse { |
21 my %arg = %{ pop @_ } if ref $_[-1] eq 'HASH'; |
23 my %arg = %{ pop @_ } if ref $_[-1] eq 'HASH'; |
22 my $data = shift; |
24 my $data = shift; |
23 my @lines = split /\n/, $data; |
25 my @lines = split /\n/, $data; |
24 |
26 |
|
27 ### @lines |
|
28 |
25 my @zone; |
29 my @zone; |
26 my ($origin, $ttl, $last_label, $soa_seen); |
30 my ($origin, $ttl, $last_label, $soa_seen); |
27 |
31 |
28 foreach (@lines) { |
32 foreach (@lines) { |
29 s{;.*$}{}; |
33 s{;.*$}{}; # strip trailing comments |
30 given ($_) { |
34 s{\s*$}{}; # strip off trailing spaces |
|
35 for ($_) { |
31 when (m{^\s*$}) { next } |
36 when (m{^\s*$}) { next } |
32 when (m{^\s*\$ORIGIN\s+(\S+)}) { $origin = $1 } |
37 when (m{^\s*\$ORIGIN\s+(\S+)}) { $origin = $1 } |
33 when (m{^\s*\$TTL\s+(\S+)}) { $ttl = $1 } |
38 when (m{^\s*\$TTL\s+(\S+)}) { $ttl = $1 } |
34 when ( |
39 when ( |
35 m{^(?:(?<label>\S+)(?=\s))? |
40 m{^(?:(?<label>\S+)(?=\s))? |