if ($st =~ /, CA\b/) { $st =~ s/, CA\b/, California/; print "$st\n"; } #### if ($st =~ s/, CA\b/, California/) { print "$st\n"; }