baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
why is this procedure so slow:
so what i'm doing is starting the second program that starts the first one , takes its stdout and parses its results to a file: the line that first one reads looks like:--first_program.pl-- use strict; #use warnings; open (F, "<", "test.out"); while(<F>){ print "$_"; } -- second program-- use strict; use warnings; my $name = ''; my @id_list; open (STDIN,"perl first_program.pl|") || die "$!"; open (OUT, ">", "out.txt") || die "$!"; # chomp std line in while(my $line_in =<STDIN>){ chomp($line_in); my @line_array = split('\t',$line_in); my @subline_array = split('\|', $line_array[1]); @id_list = () unless ($name eq $line_array[0]); $name = $line_array[0] unless ($name eq $line_array[0]); next if (grep{$_ == $subline_array[3]}@id_list); push(@id_list,$subline_array[3]); print OUT "$line_in\n"; }
without parsing the procedure takes only 3 min (but i'm writing the lines of test directly into the file not stdout) and with parsing it it takes something like 2hmmenr hh|gg|kk|3445|uu|zzz 234 wwe we qw 233
is there a way to speed this up?
thnx
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: slow parser how to make it faster
by shmem (Chancellor) on Jun 09, 2009 at 13:14 UTC | |
by ig (Vicar) on Jun 11, 2009 at 08:39 UTC |