lib/DNS/Vi.pm
changeset 61 bedb2cce973e
parent 60 34d98030d4c0
child 62 aff0448cbef9
--- a/lib/DNS/Vi.pm	Wed Jan 14 09:18:35 2015 +0100
+++ b/lib/DNS/Vi.pm	Wed Jan 21 20:33:49 2015 +0100
@@ -17,17 +17,22 @@
 # 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);
 
+# input $arg - hash with options
+#       $data - a long string with the zone data
 sub parse {
     my %arg   = %{ pop @_ } if ref $_[-1] eq 'HASH';
     my $data  = shift;
     my @lines = split /\n/, $data;
 
+    ### @lines
+
     my @zone;
     my ($origin, $ttl, $last_label, $soa_seen);
 
     foreach (@lines) {
-        s{;.*$}{};
-        given ($_) {
+        s{;.*$}{};  # strip trailing comments
+	s{\s*$}{};  # strip off trailing spaces
+        for ($_) {
             when (m{^\s*$})                { next }
             when (m{^\s*\$ORIGIN\s+(\S+)}) { $origin = $1 }
             when (m{^\s*\$TTL\s+(\S+)})    { $ttl = $1 }