- if (defined $+{RE}) {
- # We must save important %+ values, because the s///
- # below clears them
- my $re = $+{RE};
- my $subst = $+{SUBST};
-
- $variable_value =~ s/\Q$re\E/$subst/g;
-
- if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
- print STDERR
- "DEBUG[\$expand_variables] ... and substituted ",
- "'$re' with '$subst'\n";
+ if (defined $mod) {
+ if ($mod =~ /^${variable_subst_re}$/) {
+ my $re = $+{RE};
+ my $subst = $+{SUBST};
+
+ $variable_value =~ s/\Q$re\E/$subst/g;
+
+ if ($ENV{CONFIGURE_DEBUG_VARIABLE_EXPAND}) {
+ print STDERR
+ "DEBUG[\$expand_variables] ... and substituted ",
+ "'$re' with '$subst'\n";
+ }