in reply to regex CA to California
Aside from the aforementioned problem with the comma, you're substituting the contents of $_ (since you didn't say otherwise using =~). Fix:
if ($st =~ /, CA\b/) { $st =~ s/, CA\b/, California/; print "$st\n"; }
But why match twice? The following suffices.
if ($st =~ s/, CA\b/, California/) { print "$st\n"; }
|
|---|