[dean:~]$ perl -v This is perl, v5.8.1-RC3 built for darwin-thread-multi-2level (with 1 registered patch, see perl -V for more detail) Copyright 1987-2003, Larry Wall ... [dean:~]$ cat /tmp/deleteme.pl #!/usr/bin/perl use strict; use warnings; my $patt = shift; $patt = qr/$patt/; my $target = shift || 'aBC'; print "'$target' =~ $patt\n"; print $target =~ $patt; print $/; [dean:~]$ /tmp/deleteme.pl 'a\Ubc' Unrecognized escape \U passed through in regex; marked by <-- HERE in m/a\U <-- HERE bc/ at /tmp/deleteme.pl line 6. 'aBC' =~ (?-xism:a\Ubc) #### #!/usr/bin/perl use strict; use warnings; no warnings "uninitialized"; my $patt = 'a\Ubc'; $patt =~ s/(^|[^\\])(\\\\)*\\U(.*?)(?:\\E|$)/$1.$2.uc($3)/se; $patt = qr/$patt/; my $target = 'aBC'; print "'$target' =~ $patt\n"; print $target =~ $patt; print $/;