#!/usr/bin/perl -- use warnings; use strict; use re 'debug'; my $chr = "this and that"; $chr =~ s/(this|that)|(\w+)/$1\U$2/g; #error reported print "$chr\n"; __END__