The scope of $x is the entire if . . . else construct. Since the condition following if is always evaluated, that is where the lone my declaration belongs.
Consider,
$ perl -Mstrict -e'if (my $x = 0) {} print $x,$/'
Global symbol "$x" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.
$
but,
$ perl -Mstrict -e'if (my $x = 0) {} elsif (1) { print $x,$/}'
0
$
I agree that that scope is not what one expects.
Update: Two more cases,
$ perl -Mstrict -e'if ($\) {print $x,$/} elsif (my $x = 0) {} else { p
+rint $x,$/}'
Global symbol "$x" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.
$
but,
$ perl -Mstrict -e'if ($\) {} elsif (my $x = 0) {} else { print $x,$/}
+'
0
$
showing that $x may be declared in an
elsif condition to narrow its scope, if not needed in previous clauses.