Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by GrandFather (Saint)
on Jul 30, 2019 at 21:51 UTC ( [id://11103633]=note: print w/replies, xml ) Need Help??


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

Questions with a significant Perl content are encouraged. Other questions, such as this one, are allowed but should be marked Off Topic:(OT) in the title.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
  • Comment on Re^5: (OT) Perl and creating a query for MongoDB

Replies are listed 'Best First'.
Re^6: (OT) Perl and creating a query for MongoDB
by ovedpo15 (Pilgrim) on Jul 31, 2019 at 06:27 UTC
    Thanks for the explanation. Will remember for the future.
Re^6: (OT) Perl and creating a query for MongoDB
by ovedpo15 (Pilgrim) on Aug 01, 2019 at 10:12 UTC
    I though about it and I will extract the reports as the are and create the wanted report with Perl. But I still not sure how to do it.
    It feels like I need to iterate through the inner array and then through the outer array.
    Can you suggest an efficient way to do this? Will update my post.

      Can you post the perl script and source data files that you used to create the report shown on you original post ? i.e.

      { "name": "test1", "all_data": [ { "sub_data": [ { "sub_name": "Test1", "sub_path": "GROUP1/Test1", "info": [ { "group": "pkgs", "values": [ "tcsh" ] }, { "group": "tcsh", "values": [ "6.13.00" ] } ] }, { "sub_name": "GROUP2", "sub_path": "GROUP2", "info": [ { "group": "pkgs", "values": [ "tcsh" ] }, { "group": "tcsh", "values": [ "6.13.00" ] } ] }, ], "all_data_name": "ROOT", "all_data_path": "/PATH/TO/ROOT" } ], "username": "erwerwcsd", "timestamp": "1564475903" }
      poj
        It looks like something like this (removed the checks):
        my $number_of_mains = 0; my $number_of_subs = 0; foreach my $main (sort(uniq(@mains_paths))) { my (@list_of_dirs,@subs_data); my $main_path = abs_path($main); find( sub { get_valid_dirs( \@list_of_dirs, $_ ) }, $main_path); my $main_name = basename($main_path); my %main_block = ( $ALL_DATA_NAME => $main_name, $ALL_DATA_PATH => $main_path ); $number_of_mains++; foreach my $dir (sort(@list_of_dirs)) { my ($sub_path,$sub_name,$relative_sub_path,$paths_all,$results +_all,@results_data,%sub_block); $sub_path = dirname($dir); $sub_name = basename($sub_path); $relative_sub_path = File::Spec->abs2rel($sub_path,$main_path) +; %sub_block = ( $SUB_NAME => $sub_name, $SUB_PATH => $relative_sub_path, ); $results_all = $dir."/".$DIR_NAME."/".$RESULTS_FILE_NAME; unless((-e $results_all) && (-s $results_all)) { next; } prase_file($results_all,\@results_data); $number_of_subs++; @{$sub_block{$RESULTS}} = @results_data; push(@subs_data,\%sub_block); } @{$main_block{$SUBS}} = @subs_data; push(@mains_data,\%main_block); } @{$all_mains{$MAIN}} = @mains_data; $all_mains{$REPORT_NAME} = $opt_href->{$REPORT_NAME}; $all_mains{$MAIN_COUNTER} = $number_of_mains + 0; $all_mains{$SUBS_COUNTER} = $number_of_subs + 0; $all_mains{$TIMESTAMP} = $start_time + 0;
        I'm trying now to understand how to do the opposite thing.

Log In?
Username:
Password:

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

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

    No recent polls found