Keep It Simple, Stupid | |
PerlMonks |
Re: iterating through json decodeby Eily (Monsignor) |
on Feb 08, 2018 at 14:38 UTC ( [id://1208716]=note: print w/replies, xml ) | Need Help?? |
\@{$ref} is the same as $ref, because @{$ref} accesses the array that $ref points to, and adding a \ gets the same reference. While accessing @_ inside a function does work, I think you should put your arguments in variable (which should be done when @_ isn't a list of similar things but each argument has its own meaning. So: (and basically replace every use of $_[0] by $ref, and $_[1] by $depth). foreach my $item (keys %{$_[0]}){ repl_mongo($key,$_[1]-1 ); } The loop variable is $item, but you access $key. Do you have strict on? It should have told you about that. And for the date conversion, after you have found that a string starts with ISODate (that's index exactly 0 by the way) you can use substr to extract the date part (which will always be at the same positions, starting from the 8th character).
In Section
Seekers of Perl Wisdom
|
|