Bladernr has asked for the wisdom of the Perl Monks concerning the following question:

Could someone show me a snippet that actually makes use of the HASH that is the product of soa() when using DNS::ZoneParse? I am working on a script to manipulate zone files and am just starting out. So far, using the info on CPAN for DNS::Parse, I can look at the various records, a, mx, etc, but trying to see the various parts of the hash for soa() has me stuck... does anyone have any examples on pulling the individual parts out?? Thanks Jeff

Replies are listed 'Best First'.
Re: DNS::ZoneParse
by revdiablo (Prior) on Aug 14, 2003 at 04:32 UTC

    While I have no experience with DNS::ZoneParse in particular, you can probably get a good idea of the structure of this hash using Data::Dumper. Once you have a dump of the datastructure, you can check perldsc to get hints on how to pull pieces from the hash. Hopefully this (overly) general advice will help you out some. :)

    Update: looking at the docs for DNS::ZoneParse, it looks like soa() returns a pretty straightforward hash reference. Maybe some code like the following will give you an idea how to use it:

    my $soa = $zonefile->soa(); print "serial: ", $soa->{serial}, "\n", "origin: ", $soa->{origin}, "\n", "primary: ", $soa->{primary}, "\n";

    Note: this is all untested code. I simply made an educated guess from the docs.

      Ahhhh... thank you. THat is what I was missing... I had something like this to print the actual hash:

      print $zonefile->$soa()"\n";

      And had some what I see now as very obviously wrong code to get the various items from the hash... Thanks! If I get this script going the way I want to, I will be sure to put it here somewhere for others to see...