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

Re: Parallel-processing the code

by ikegami (Patriarch)
on May 17, 2018 at 00:52 UTC ( [id://1214702]=note: print w/replies, xml ) Need Help??


in reply to Parallel-processing the code

As previously mentioned, multi-tasking won't help. This prorgram is I/O-bound, and merging the results of the threads would be as expensive as building the results in the first place.

I just wanted to provide a cleaned up version of your code (with a few micro-optimizations).

#!/usr/bin/perl use strict; use warnings; use feature qw( say ); use Sort::Naturally qw( nsort ); local $/ = ''; # Paragraph mode reads until a blank line. my %grouped; while (<>) { my @lines = split /\n/, $_; for (@lines[1..$#lines]) { next if $_ eq '--'; # Omit if rarely true. ++$grouped{"D$1"}{$2} while /\bD\*([^*]*)\*([^*]*)\*D\b/g; } } for my $k (nsort keys %grouped) { say "$k=>" . join("|", keys(%{ $grouped{$k} }); }

Replies are listed 'Best First'.
Re^2: Parallel-processing the code
by rajaman (Sexton) on May 19, 2018 at 04:12 UTC
    Thank you Ikegami. New thing learned there.

Log In?
Username:
Password:

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

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

    No recent polls found