develooper Front page | perl.perl5.porters | Postings from April 2008

Re: [perl #53504] Bug in if(open(my $fh,...)) { } scoping

Thread Previous | Thread Next
From:
Matt Sergeant
Date:
April 30, 2008 07:14
Subject:
Re: [perl #53504] Bug in if(open(my $fh,...)) { } scoping
Message ID:
60CB34DF-D52B-4E61-BAAB-D705E88728F5@sergeant.org
On 30-Apr-08, at 10:04 AM, Rafael Garcia-Suarez via RT wrote:

>> Yup, IMHO this was an error in judgement by whoever chose this  
>> behaviour
>> originally. But we're stuck with it now.
>
> I don't think so.
> I think the intent behind this feature's design was to allow :
>
> if ((my $ret = somecall()) == 0) {
>     # profit !
> }
> elsif ($ret == -1) {
>     # handle error code -1
> }
> elsif ($ret == -2) {
>     # handle error code -2
> }
> else { etc... }

I know. I just don't think it's used like that very much (if at  
all?), and I don't think the chosen implementation makes visual sense.

If we'd have had given/when back then I suspect the scoping would  
have been implemented differently.

Matt.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About