in reply to Re: Optimizing a script
in thread Optimizing a script

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