Skip Menu |

This queue is for tickets about the DNS-ZoneParse CPAN distribution.

Report information
The Basics
Id: 7615
Status: resolved
Priority: 0/
Queue: DNS-ZoneParse

People
Owner: Nobody in particular
Requestors: zoop [...] lone.ath.cx
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.94
Fixed in: (no value)



Subject: Error when dealing with txt records.
useing perl 5.8.3 when I update a zone file with a txt record it inserts a A for an unknown reason. Here is the part of the zone file that has the problem. www 60 A 10.1.1.7 ns1 IN A 10.1.1.2 chungfoo IN A 10.1.1.2 mail IN A 10.1.1.2 A <---------- @ IN TXT "v=spf1 a mx -all" mail IN TXT "v=spf1 a -all" www IN TXT "v=spf1 a -all"
From: zoop [...] lone.ath.cx
O also all I was updating is the IP address of www and then write the file. my $zone = DNS::ZoneParse->new($zonefile, $domain); my $arecs = $zone->a(); for ( my $x = 0; $arecs->[$x]->{name}; $x++) { if ($arecs->[$x]->{name} eq $hostname) { $arecs->[$x] = { name => $hostname , ttl => $ttl , host => $ip }; } } $zone->new_serial(1); print $fh $zone->output(); [guest - Sun Sep 12 02:28:23 2004]: Show quoted text
> useing perl 5.8.3 > > when I update a zone file with a txt record it inserts a A for an > unknown reason. Here is the part of the zone file that has the > problem. > > www 60 A 10.1.1.7 > ns1 IN A 10.1.1.2 > chungfoo IN A 10.1.1.2 > mail IN A 10.1.1.2 > A <---------- > @ IN TXT "v=spf1 a mx -all" > mail IN TXT "v=spf1 a -all" > www IN TXT "v=spf1 a -all"
Hi, Your for (;;) loop is adding an extra element to the the $arecs array: Show quoted text
> for ( my $x = 0; $arecs->[$x]->{name}; $x++) {
See 'perldoc perlref' and the section on autovivication: http://www.perldoc.com/perl5.8.4/pod/perlref.html Can you try changing your updating code to: my $zone = DNS::ZoneParse->new($zonefile, $domain); my $arecs = $zone->a(); foreach my $record (@$arecs) { next unless defined record; if ($record->{name} eq $hostname) { $record->{host} = $ip; $record->{ttl} = $ttl; } } $zone->new_serial(1); print $fh $zone->output(); Thanks --simonflk
You could also fix it by changing for ( my $x = 0; $arecs->[$x]->{name}; $x++) { to: for ( my $x = 0; $arecs->[$x]; $x++) { --simonflk