>>    sub getfh {
>>      return open(my $fh, "+< /dev/null") && $fh;
>>    } 

>Aha! You fell for one of my pet pieves. You tried to return a lexical in
>the same expression were it was declared. That doesn't work. It's not
>the same variable. Running it with warnings enabled says:

Grr..

>   Name "main::fh" used only once: possible typo at test.pl line 3.

>I feel that this ought to have worked, i.e. that the scope of the
>lexical kicked in in the middle of the expression, at the transition
>over the shortcut operator "&&".

Except that then you can't say

    local $x = $x;
or
    my $x = $x;

--tom

Reply via email to