diff -r 9069ce49fd83 -r 140d7537105e lib/DNS/Vi.pm --- a/lib/DNS/Vi.pm Thu Jul 14 10:30:58 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,317 +0,0 @@ -package DNS::Vi; -use 5.0101; -use strict; -use warnings; -use if $ENV{DEBUG} // '' eq 'dnsvi' => 'Smart::Comments'; -use Digest::SHA qw(sha512_hex); -use File::Temp; -use Net::DNS; -use Term::ReadKey; -use base 'Exporter'; -use if $] >= 5.020, experimental => 'smartmatch'; - -our @EXPORT = qw(ttl2h h2ttl parse delta nice edit update show get_key - get_auth_info); -our @EXPORT_OK = (); - -# the sort order for the records of the same label -my %ORDER = map { state $n = 0; $_ => ++$n } qw(SOA NS TXT MX A AAAA SSHFP); - -sub h2ttl(_); - -# input $arg - hash with options -# $data - a long string with the zone data -sub parse { - my %arg = %{ pop @_ } if ref $_[-1] eq ref {}; - my $data = shift; - my @lines = split /\n/, $data; - - my @zone; - my ($origin, $ttl, $last_label, $soa_seen); - - $_ = ''; - foreach (@lines) { - # simplificated comment remover - # after the comment character no '"' is allowed! -# s{^\s*;.*$}{}; # strip comment lines -# s{\s*;[^"]*$}{}; # strip trailing comments - - # see https://regex101.com/r/cG6fK3/2 - s{\s*(?:;)(?:(?:[^"]|"[^"]*")*$)}{}; - state $line; - if (my $range = /(.*)\(\s*$/ .. /(.*)\)\s*/) { - $line .= defined $1 ? $1 : $_; - next unless $range =~ /E0$/; - } - if (defined $line) { - $_ = $line; # accumulated continuation line - $line = undef; - } - s{\s*$}{}; # strip off trailing spaces - given ($_) { - when (m{^\s*$}) { next } - when (m{^\s*\$ORIGIN\s+(\S+)}) { $origin = $1 } - when (m{^\s*\$TTL\s+(\S+)}) { $ttl = $1 } - when ( - m{^(?:(?