I'm working with the Perl API of an Infoblox appliance (doc: https://ipam.illinois.edu/api/doc/)
I have the following code:
...
my $specificRecord = $recordResults[0];
say $specificRecord->name();
foreach ($specificRecord->ipv4addrs())
{
say $_;
}
$specificRecord contains an Infoblox::DNS::Host record object.
My problem comes when I'm iterating over ipv4addrs(). According to the documentation and the perl debugger, ipv4addrs() returns an ARRAY containing IPs or DHCP::FixedAddr objects.
In my case, if I debug my program and "x" $specificRecord->ipv4addrs() as well as $_, I get the same result:
DB<1> b 70
DB<2> c
Results: 1
aaaa9999test.justice
main::(testScript2.pl:70): foreach ($specificRecord->ipv4addrs())
main::(testScript2.pl:71): {
DB<2> x $specificRecord->ipv4addrs();
0 ARRAY(0x64e9e3c)
0 '8.8.8.8'
1 '8.8.4.4'
DB<3> n
main::(testScript2.pl:72): say $_;
DB<3> x $_;
0 ARRAY(0x64e9e3c)
0 '8.8.8.8'
1 '8.8.4.4'
Here is a relevant portion of "x" of the Infoblox::DNS::Host object:
DB<2> x $specificRecord;
0 Infoblox::DNS::Host=HASH(0x8b3eacc)
'__object_id__' => 'dns.host$._default.justice.aaaa9999test'
'aliases' => ARRAY(0x8b3e9fc)
empty array
'configure_for_dns' => 'true'
'disable' => 'false'
'ipv4addrs' => ARRAY(0x64e9e3c)
0 '8.8.8.8'
1 '8.8.4.4'
'ipv6addrs' => ARRAY(0x8aa1bac)
empty array
'name' => 'aaaa9999test.justice'
...
I can't tell what I'm doing wrong and why foreach doesn't work with the $_ variable. I tried assigning ipv4addrs() to an array and then foreaching over that, to no avail.
It's returning an array reference. Try dereferencing it:
foreach ( @{ $specificRecord->ipv4addrs() } )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With