in reply to Optimizing a script

I think your problem is in the line
$/ = qq{"\$"\t""\t""\n};
I looked at the other thread and what you're using here does not match the data you described there. I have a feeling that your script is trying to find a match for a record separator that doesn't exist, and therefore tried to read the whole file into memory, and got hopelessly bogged down with swapping as a consequence.

Your record separator isn't "$"<TAB>""<TAB>""(newline) is it? I think you need to get rid of all those " characters, for starters...

Replies are listed 'Best First'.
Re: Re: Optimizing a script
by Micz (Beadle) on Apr 21, 2004 at 15:03 UTC
    Hi Matija, everyone thanks for your help. I changed the regexp to qq{"\$"\t""\t""};, that solved my first problem. Now, the script won't give the files the names I want, it continues to overwrite .csv. I have changed the script a bit to
    my $i = 1; while ( <A> ) { my $file = ( split /\n/, $_ )[1] or next; ( $file ) = $file =~ m/"(.*?)"/ or next; $file = $i; open B, "> $file.csv" or warn( "Cannot open '$file': $!" ), next; print "[DEBUG] '$file': open ok\n"; chomp $_; print B $_; close B or warn( "Cannot close '$file': $!" ), next; print "[DEBUG] '$file': close ok\n"; $i++; }
    Which gives the files the names 1, 2, 3 etc. But I would like the filenames to be the name of the company. How can I achieve this? Thanks,

    Jan