in reply to Re: Replacing consecutive tokens in 1 pass
in thread Replacing consecutive tokens in 1 pass

You can still use the split()/join() approach, if you utilize the LIMIT argument of split().
my $string = "|90|93|foo|bar|91|92|95|96|906|"; my $result = join '|', map { s/^9[0-6]$/X/; $_ } split /\|/, $string, -1; print $result; __END__ |X|X|foo|bar|X|X|X|X|906|
ihb