in reply to returning nested data structures

Sorry - I tried returning \%filters first, but that didn't work. The code I posted is in a sub within a module, because I need to use it in several programs. Here's what I'm doing in the main program (when returning \%filters):
my($filters_ref) = GetFilters($filters_file); %filters = %$filters_ref; print \%filters; foreach (keys %filters) { print; }
I get a hash reference with the first print line but nothing with the second. I've tested the data in the hash and it's perfectly correct before I return it.

Replies are listed 'Best First'.
Re^2: returning nested data structures
by gube (Parson) on Dec 22, 2009 at 22:32 UTC
    Hi,

    1) Can you print Dumper(\%filters) and check whether its reference of reference.

    2) Otherwise, try foreach (keys %{$filters_ref}) { print; } and see it works

    Gubs