in reply to Increase speed script

marto9:

I believe that the primary speed problem is due to you opening and closing the output file in your cleaning loop. You should open the file before starting the loop, then write out all your data, and close at the end:

print "[-] Cleaning...\n"; open(OUTPUT,">>cleaned.txt") or die "Can't open cleaned.txt!"; foreach $data (@file1) { ($w1) = split(/:/,$data); print OUTPUT $w1."\n" unless ($data =~ /-/); } close(OUTPUT) or die "close error";

A couple of minor items:

...roboticus

UPDATE: Fixed a bit of awkward grammar, added some formatting for readability.

Replies are listed 'Best First'.
Re^2: Increase speed script
by marto9 (Beadle) on Jul 11, 2008 at 14:27 UTC
    Thx roboticus! That speeded up my script A LOT. :) And I also added some "or die" code in it.