I try to do regex matching:
$address =~ s/$re_region//;
$new_address_h->{ region } = $1 //'';
# $1 = undef; # ERROR: Modification of a read-only value attempted at ...
$address =~ s/$re_city//;
$new_address_h->{ city } = $1;
When city is not matched I want it is filled with undef. But when city is not matched $1 has value from previous match. Why? I expect that when matching fails then its output has no values, even special variables. like eval flushes $@
Is it possible without additional ifs?