in reply to Re^2: Data::Dumper / write output into Mysql
in thread Data::Dumper / write output into Mysql

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.

Replies are listed 'Best First'.
Re^4: Data::Dumper / write output into Mysql
by steph007 (Initiate) on Nov 05, 2015 at 13:41 UTC
    I'm guessing I'll be doing something like this to check whether the entire $result is undef ?
    unless (defined($result)) { ....blah }