in reply to RE: RE: RE: Making a Hash of Arrays
in thread Making a Hash of Arrays

except, when I try and print the returned hash:
my %first_hash = processfile($file2, $list2); foreach my $k (sort keys %first_hash){ print "$k\n$first_hash{$k}\n"; }
it returns:
MonName ARRAY(0xcb420) SrcRtr ARRAY(0xcb468) ifSpeed ARRAY(0xcb444)
rather than the value of the keys.

Replies are listed 'Best First'.
RE: RE: RE: RE: RE: Making a Hash of Arrays
by japhy (Canon) on Sep 23, 2000 at 00:42 UTC
    That's because they're REFERENCES to arrays. You need to dereference them (@{ $array_ref }).

    $_="goto+F.print+chop;\n=yhpaj";F1:eval
RE(5)Making a Hash of Arrays
by Adam (Vicar) on Sep 23, 2000 at 00:44 UTC
    So you need to dereference the arrays. @$arrayref.

    If you just need to know what's in the hash, use Data::Dumper. It does a great job of expanding references and can be made to do all sorts of pretty printing.

    use Data::Dumper; print Data::Dumper->Dump([\%yourhash], ["name of your hash"]), "\n";
    You can also use that to print your arrays and such.