#!/usr/bin/perl use warnings; use strict; # 856624 my $str = 'abccabbcabc'; my @chars = split(//, $str); my $seen = '-'; for my $char(@chars) { if ($char =~ $seen ) { print $char . "\t|\t"; # skip the tabs and pipe if desired } else { $seen = $char; } } =head Output: c | b | =cut