Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^11: (OT) Perl and creating a query for MongoDB

by poj (Abbot)
on Aug 03, 2019 at 11:02 UTC ( [id://11103795]=note: print w/replies, xml ) Need Help??


in reply to Re^10: (OT) Perl and creating a query for MongoDB
in thread (OT) Perl and creating a query for MongoDB

it will be clear ..

It's not clear to me how this code

foreach my $k (@{$aref}) { if ($k->{"group"} eq $group) { $k->{"version"} = [ sort uniq $version, @{$k->{"version"}} ]; $key = 0; } } push @{ $aref }, { group => $group, versions => [ $version ] } if ($key);

can create this data structure

{ "group": "pkgs", "values": [ "tcsh" ] },

Is the key 'version', 'versions' or 'values' ?

poj

Replies are listed 'Best First'.
Re^12: (OT) Perl and creating a query for MongoDB
by ovedpo15 (Pilgrim) on Aug 03, 2019 at 11:58 UTC
    Oh sorry, the code is: (too many changes and I was looking at the old version)
    open(my $fh, '<', "$file_path") or return 0; while (my $line = <$fh>) { chomp($line); my ($key,$group,$value,$version,$file,$count) = split(/,/,$lin +e); my $key = 1; foreach my $k (@{$aref}) { if ($k->{"group"} eq $group) { $k->{"values"} = [ sort uniq $value, @{$k->{"values"}} ]; $key = 0; } } push @{ $aref }, { group => $group, values => [ $value ] } if ($key); } close ($fh);

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (2)
As of 2024-04-20 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found