#!/usr/local/bin/perl -w # $fn1 = '/in.CSV'; # Useless stringification, and check your errors # open (INST,"$fn1") open(INST, '<', $fn1) or die "Unable to open '$fn1' for reading: $!"; # Preference, but possibly a better habit # consider: open(ABI, ">$foo") where $foo # contains ">blah". # Also - check your errors # open (ABI,">/out.ins"); open(ABI,">", "/out.ins") or die "Unable to open /out.ins: $!"; while () { # Moved from below - fail fast [1] next if /^"Branchno"\t/; next if /^""\t/; # Not necessary [3] # chomp; # Fishy - does this remove the last \t? [2] # chop; s/\õ/\ä/g; s/\"-/\"Ä/g; s/\--/\-Ä/g; s/\ - /\*-*/g; s/\ -/\ Ä/g; s/\*-*/\ - /g; s/\"_/\"Ü/g; s/\ _/\ Ü/g; s/\__/\_Ü/g; s/\³/\ü/g; s/\§/\õ/g; # @array = ' '; # Not necessary, useless # no longer necessary [1,2] # @array = split(/\t/); # Moved to top of loop - fail fast [1] # if ($array[0] eq "\"Branchno\"") { next; } # if ($array[0] eq "\"\"" ) {next;} # No longer necessary, assuming chop above removed \t [2] # $result = join ("|",@array)."|"; # Replace split / join with another s/// [2] s/\t/|/g; # Work on $_, no longer need $result # $result =~ s/\"//g; # print ABI $result,"\n"; s/"//g; # newline not necessary since chomp removed [3] print; } close (INST); close (ABI);