in reply to Hash reference undefined somewhere?

It doesn't appear that GetHosts actually returns explicitly. Trying assigning your functions to temporary variables that you can debug first:
my $get_hosts = GetHosts($_, \%data); my $get_new = GetNewFWRules($_, \%data); print "Do I equal what you think i do? get_hosts = '$get_hosts'\n"; print "Do I equal what you think i do? get_new = '$get_new'\n"; my %do_for = ( get_hosts => $get_hosts, get_new_fw_rules => $get_new, );
If for example, the functions are supposed to return arrays, you might need the following:
my %do_for = ( get_hosts => [GetHosts($_, \%data)], get_new_fw_rules => [GetNewFWRules($_, \%data)], );

Replies are listed 'Best First'.
Re^2: Hash reference undefined somewhere?
by bowei_99 (Friar) on Mar 09, 2011 at 23:23 UTC
    I tried that, and I still get the same thing. I think the issue is that it's getting into the subroutine, but erroring out in that subroutine, so it never exits that subroutine, making it a moot point what it returns. This is what I did:

    Updated with debug statements:

    print "DEBUG: get_host: " . GetHosts($_, \%data) . "\n"; print "DEBUG: get_new_fw: " . GetNewFWRules($_, \%data) . "\n" +; my %do_for = ( get_hosts => GetHosts($_, \%data), get_new_fw_rules => GetNewFWRules($_, \%data), ); #print "while\n"; print "DEBUG: do_for: " . $do_for{$what_to_do} . "\n";
    and added return values to the subroutine:

    sub GetHosts { .... return 1; }

    I get the same error and output as before, and none of the new debug statements are printed.

    -- Burvil