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.
In reply to Re: replace nth occurrence of |
by clueless newbie
in thread replace nth occurrence of |
by perl197
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |