in reply to Re: help! Please please help!
in thread help! Please please help!

Corion, thanks! I'll rememeber that for next time! Right, basically that line is supposed to replace the value in server, which is blank, with nothing. I realise it wont do that now, but if I take it out it just says this now.

"Cant coerce arrays into has at line 39"

Most of the time the array will be blank, does that matter? Its still that line

Replies are listed 'Best First'.
Re^3: help! Please please help!
by Corion (Patriarch) on Mar 14, 2008 at 12:51 UTC

    Maybe you can tell us what line 39 is?

    If you want people to easily check your code, please edit your above node and put your code in between <code>...</code> tags. That way, it will render and download nicely for everybody.

    It also often helps to supply example data with the program, or to reduce the program so it doesn't need any external data anymore yet still reproduces the problem.

    As for your concrete problem, you seem to be confused about the data structure you have. The line

    foreach my $type ( @{$rbl_list{$omr}{blackholes} })

    tries to access the values in %rbl_list as a hash, but before that, you filled it with references to arrays. I find that using Data::Dumper often helps to visualize the data structure and to find where my assumptions about the data structure do differ from reality.

      Corion,
      That line you mentioned is line 39!

      Right, ill have a go with data::dumper and see where it gets me.

      Im still confused though, i thought I was refereing to a line in hash, which had the IP's as the keys and the results stored in an array, as there might me more than one and I needed to refer to them serperatly. Or do I have the worng end of the stick there?

      Cheers

        Net::RBLClient's listed_by() method returns a list of servers blocking an IP. You assign this to an array, and assign a reference to that array to an element of your hash. If you want to iterate over that array, you can just use something like the following instead of your foreach:

        #This line isn't needed anymore #my $blackholes = $tpl->new_loop("listings", $omr); for my $server ( @{$rbl_list{$omr}} ) { #do something for each server in the array }
Re^3: help! Please please help!
by amarquis (Curate) on Mar 14, 2008 at 12:56 UTC

    The issue is that you are trying to access an array element like a hash element. You put array refs into a hash here:

    $rbl_list{$ip} = \@listed_by;

    And later access like this:

    @{$rbl_list{$omr}{blackholes}

    $rbl_list{$omr} is an array ref, so $rbl_list{$omr}{blackholes} is like saying $arrayref->{$somekey}. (You also probably want $blackholes not the bareword blackholes)

    Edit: I am undone by corion's speed.