$b = "c"; { no warnings 'uninitialized'; # turn off bogus warning for this block $b =~ s/^(?:a(\w))?(\w)$/$1:$2/; # voilla, no warning!! }