use warnings; use strict; my $string = 'Three, Four, One, Two, xFive9, six, Seven'; my $number = qr{ \b [[:upper:]] [[:lower:]]+ \b }xms; print qq{string is now '$string' \n}; my $ordinal = 0; $string =~ s{ ($number) } { ask_replace(++$ordinal, $-[1], $1) }xmsge; print qq{new string is '$string' \n}; print qq{done! \n}; sub ask_replace { my ($ordinal, $offset, $string, ) = @_; my $yes = qr{ (?i) y (?: e (?: s)? )? }xmso; my $ok = qr{ (?i) o (?: k)? }xmso; my $accept = qr{ \A (?: $yes | $ok) \Z }xmso; print qq{sub-string $ordinal at offset $offset is '$string' \n}; print qq{is this correct? }; my $answer = ; return $string if $answer =~ $accept; print qq{no: enter new string: }; chomp(my $replace = ); return $replace; } #### c:\@Work\Perl\monks\Keystone>perl ask_to_replace_1.pl string is now 'Three, Four, One, Two, xFive9, six, Seven' sub-string 1 at offset 0 is 'Three' is this correct? n no: enter new string: Uno sub-string 2 at offset 7 is 'Four' is this correct? No no: enter new string: Dos sub-string 3 at offset 13 is 'One' is this correct? y sub-string 4 at offset 18 is 'Two' is this correct? x no: enter new string: Tres sub-string 5 at offset 36 is 'Seven' is this correct? n no: enter new string: se7en new string is 'Uno, Dos, One, Tres, xFive9, six, se7en' done!