my $variable; if (1 == 1) { my $value = 'a'; $variable = $value; } else { my $value = 'b'; $variable = $value; } # => '$variable' now contains 'a'