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

Re: my $foo = "bar" if $baz;

Thread Previous | Thread Next
From:
Dmitry Karasik
Date:
July 11, 2008 06:57
Subject:
Re: my $foo = "bar" if $baz;
Message ID:
20080711060230.GA24237@tetsuo.karasik.eu.org
 On 11 Jul 2008, at 02:30, David Golden wrote:
>> From perldelta on 5.10.0:
>
> Deprecated use of my() in false conditional
> A new deprecation warning, *Deprecated use of my() in false
> conditional*, has been added, to warn against the use of the
> dubious
> and deprecated construct
>
> my $x if 0;
>
> I'd always heard not to initialize my variables in a conditional
> statement.

I always wandered, if that statement turned out to produce bad
side effect, wouldn't it be more sane to convert it to a useful one,
f.x. translate 'my $foo = "bar" if $baz' to 'my $foo; $foo = "bar" if $baz"?
That would be both expected and useful.

-- 
Sincerely,
	Dmitry Karasik


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