open($fh, '<:encoding(UTF-8)', $outfilename) or die "Could not open file '$outfilename' $!"; # open the file that had 9 |'s overtly set. open(OUT, ">$outfileload") or die "Unable to open $outfilename for writing: $!\n"; # replace the 10th, 11th, and 12th |'s with pipe so the field can be loaded into an expanded varchar field without treating the data as more than one field. while ($row = <$fh>) { my $pos1 = 10; $row =~ s/(\|)/!--$pos1 ? ' pipe ' : $1/ge; my $pos2 = 11; $row =~ s/(\|)/!--$pos2 ? ' pipe ' : $1/ge; my $pos3 = 12; $row =~ s/(\|)/!--$pos3 ? ' pipe ' : $1/ge; chomp $row; print OUT "$row\n"; } print "doneagain\n";