Why doesn't "local($foo) = ;" work right?

local gives list context to the right hand side of =. The < FH> read operation, like so many of Perl's functions and operators, can tell which context it was called in and behaves appropriately. In general, the scalar function can help. This function does nothing to the data itself (contrary to popular myth) but rather tells its argument to behave in whatever its scalar fashion is. If that function doesn't have a defined scalar behavior, this of course doesn't help you (such as with sort).

To enforce scalar context in this particular case, however, you need merely omit the parentheses:

    local($foo) = <FILE>;	    # WRONG
    local($foo) = scalar(<FILE>);  # ok
    local $foo  = <FILE>;	    # right

You should probably be using lexical variables anyway, although the issue is the same here:

    my($foo) = <FILE>;	# WRONG
    my $foo  = <FILE>;	# right