in reply to access object values

The best way to drill that down is to follow the classes of the objects.

  1. A Net::DNS::Packet object has the object method answer (You've already figured that out).
  2. According to the docs, that answer is a list of Net::DNS::RR objects. These have a type method, which will provide you with 'PTR' (I'm assuming that from your dump).
  3. Finally, Net::DNS::RR::PTR objects have a method ptrdname, which provides you with a the string '20.bl.bot.semrush.com'. You get the same result from calling $answer->rdstring, which works for all types of RR records.

In code:

use 5.020; my @answers = $obj->answer; for my $answer (@answers) { if ($answer->type eq 'PTR') { $ptrdname = $answer->ptrdname; } } say $ptrdname;

Replies are listed 'Best First'.
Re^2: access object values
by averlon (Sexton) on Jun 05, 2023 at 11:13 UTC
    Hi haj, thanks - I will try that way!

    Problem is, that I did not understand the docu in the right way that this is a kind of drill down through different objects and methods.

    Beside this, this also gives me the array. But your solution is much better!
    $obj{answer}->[0]{ptrdname}{label}
    Regards Kallewirsch