Hello,
I wonder what it would be the right way to treat anonymous references in lists. I have a list like this:
Code:
$element = ['one', 'two', {'3' => 'three', '4' => 'four'}, 'five'];
and when in a loop I want to print it, I get the error "Can't call method "treat" on unblessed reference":
Code:
treat( $element);
sub treat {
@array = @{$_[0]} if ref( $_[0]) eq "ARRAY";
@array = values %{$_[0]} if ref( $_[0]) eq "HASH";
for( @array) {
if( ref( $_) eq "HASH") {
treat $_;
}
else {
print "$_ ";
}
}
};
I get 'one two' and the error message, and not the 'one two three four five'.
Thank you in advance.