in reply to Re: Regexp: Only tr second occurancein thread Regexp: Only tr second occurance
sub delete_nth { my ( $str, $pat, $n ) = @_; my $cap = "$pat.*" x ( $n - 1 ); $str =~ s/($cap)$pat/$1/; return $str; } [download]
Makeshifts last the longest.