in reply to script optimization
your loop does chomp AND chop. Why? It there a trailing character that needs to be removed?
Your loop initializes @array twice in every iteration. That takes unneeded time (you asked for speedups)
You escape too many characters that do not need escaping.
You can combine single character replacements into a single tr/// call
use strict; use warnings; my ($fi, $fo) = ("/in.CSV", "/out.ins"); open my $hi, "<", $fi or die "$fi: $!\n"; open my $ho, ">", $fo or die "$fo: $!\n"; while (<$hi>) { chomp; chop; # <-- is this really needed? tr/õ³§/äüõ/; s/ - /*-*/g; s/\*-*/ - /g; # <-- is this really what you want? s/([" _])-/$1Ä/g; s/([" _])_/$1Ü/g; my @array = split /\t/ => $_, -1; $array[0] =~ m/^"(?:Branchno)?"$/ and next; (my $result = join "|" => @array, "") =~ tr/"//d; print $ho $result, "\n"; } close $hi; close $ho;
|
|---|