Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Converting some MapReduce PHP scripts to Perl

by duyet (Friar)
on Aug 13, 2011 at 06:07 UTC ( [id://920148]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Converting some MapReduce PHP scripts to Perl
in thread Converting some MapReduce PHP scripts to Perl

As you mentioned, the data contains an array and a hash, it needs more than just a print ... I'm sure there are many ways to do it but here is what i have ...
foreach my $key ( keys %data ) { my $out = ''; foreach my $s ( @{ $data{$key}} ) { if ( ref $s eq 'ARRAY' ) { $out .= '[' . ( join ',', @$s ) . ']'; } else { while ( my ($k,$v) = each %$s ) { $out .= ",{\"$k\":$v}"; } } } print $key . "\t[$out]\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://920148]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found