Skip Menu |

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

Report information
The Basics
Id: 22713
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: hachi [...] cpan.org
Cc:
AdminCc:

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



Subject: Unable to create empty Net::DNS::Packet
When working with Net::DNS... I'm trying to create an empty Net::DNS::Packet object (so I can populate it with things iteratively) and the code is leaving me no way to create one with 0 questions. If I say: my $packet = Net::DNS::Packet->new(); $packet is now a question packet requesting the '' (empty string) domain name IN class A type. To remove this I have to then: $packet->pop('question'); This really doesn't look good in code, so I'd suggest that a void argument list should create an empty packet.
Subject: Re: [rt.cpan.org #22713] Unable to create empty Net::DNS::Packet
Date: Wed, 1 Nov 2006 09:54:12 +0100
To: bug-Net-DNS [...] rt.cpan.org
From: "Olaf M. Kolkman" <olaf [...] dacht.net>
On 1Nov 2006, at 12:10 AM, via RT wrote: Show quoted text
> When working with Net::DNS... I'm trying to create an empty > Net::DNS::Packet object (so I can populate it with things iteratively) > and the code is leaving me no way to create one with 0 questions. > > If I say: > > my $packet = Net::DNS::Packet->new(); > > $packet is now a question packet requesting the '' (empty string) > domain > name IN class A type. > > To remove this I have to then: > > $packet->pop('question'); > > This really doesn't look good in code, so I'd suggest that a void > argument list should create an empty packet.
I agree this is counter intuitive (I've been bitten by it myself) but since Net::DNS has a deployment base changing this behavior would break quite a lot of code. There might be some milage in creating a Header object first and providing the data from that object as input to the Packet constructor. Something like: my $data=$header->data; my $packet=Net::DNS::Packet->new(\$data); (Not sure, have not tested) --Olaf ------------------------------------------------------ Ik dacht net... heel even maar.
Download PGP.sig
application/pgp-signature 227b

Message body not shown because it is not plain text.