|go ahead... be a heretic|
Converting some MapReduce PHP scripts to Perlby regan99 (Initiate)
|on Aug 12, 2011 at 22:06 UTC||Need Help??|
regan99 has asked for the
wisdom of the Perl Monks concerning the following question:
I have a two PHP scripts that I am using for hadoop streaming, crunching some JSON data. For various reasons, I am trying to translate these scripts to Perl, but having a tough time. I actually managed to get the mapping script translated (I kinda cheated and used a regex to get around dealing with processing JSON data) but the reduce script is more complex. For starters, here's the sorted output from the mapping script (each line is a key, followed by a tab, followed by a value with a newline ending each line):
And here is the PHP code that does the reducing:
Particularly, this is the part I can't figure out how to translate:
I placed a couple of echos in that PHP code to see what values wind up in $value and $value1, and here's what they get with the first line of the input data:
I can see that json_decode call basically takes the value and converts it to a multidimensional array and assigns them to $value. I don't quite understand what the get_objects_var call does to $value1 but the end result is that it contains another array containing a key->value pair.
My question is, how hard would it be to do the same thing in Perl? I took a look at the JSON module documentation, but didn't understand how to wind up with the same results this PHP code gets. Any takers on giving me a hand with this?