On a modern enough perl you can use the defined-or operator // to use an empty hashref instead. eg:
use strict; use warnings; my $result = { '10.4.20.21' => undef }; for my $mac (values %{(values %$result)[0] // {}}) { print "Mac addr: $mac\n"; }
Of course, if your entire $result is undef then you could easily check for this separately before even hitting the for loop.
In reply to Re^3: Data::Dumper / write output into Mysql
by hippo
in thread Data::Dumper / write output into Mysql
by steph007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |