in reply to replace nth occurrence of |

If you started with 12 and worked down to 10

while ($row = <$fh>) { my $pos1 = 12; $row =~ s/(\|)/!--$pos1 ? ' pipe ' : $1/ge; my $pos2 = 11; $row =~ s/(\|)/!--$pos2 ? ' pipe ' : $1/ge; my $pos3 = 10; $row =~ s/(\|)/!--$pos3 ? ' pipe ' : $1/ge; chomp $row; print OUT "$row\n"; }

it should work.