Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
Thanks
Can I get some better approach to modify the below script, so that execution will be faster.
Currently I am iterating array of large number of records to compare the macthing string occur in a file (30000 lines).
and matching record store in a text file called Result_file.txt
Can anyone please help me to improve the performance of the above mentioned code# The array @tag contains around 40000 records # Input_file.dat contains 30000 lines open(FH1,"+>Result_file.txt") or die "Cannot create file $!\n"; foreach my $fkey(@tag) { open(FH,"<Input_file.dat") or die "Cannot read $!\n"; while(<FH>) { if($_ =~ m/$fkey/g) { print FH1 "$_\n"; } } close(FH); } close(FH1);
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Better solution to the code
by moritz (Cardinal) on Jan 25, 2008 at 10:20 UTC | |
Re: Better solution to the code
by Punitha (Priest) on Jan 25, 2008 at 09:53 UTC | |
by hipowls (Curate) on Jan 25, 2008 at 10:28 UTC | |
Re: Better solution to the code
by Lu. (Hermit) on Jan 25, 2008 at 10:30 UTC | |
by moritz (Cardinal) on Jan 25, 2008 at 10:35 UTC | |
by cdarke (Prior) on Jan 25, 2008 at 12:56 UTC |
Back to
Seekers of Perl Wisdom