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

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

Thread Previous | Thread Next
Dmitry Karasik
July 11, 2008 06:57
Re: my $foo = "bar" if $baz;
Message ID:
 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.

	Dmitry Karasik

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About