in reply to Re^2: A curious case of of my()
in thread A curious case of of my()

>The code presented is strict clean, and warnings free. Don't go pretending strict and warnings are silver bullets. They aren't.

But garlic and cheaper than bullets!

use strict; use warnings; sub tst { my $y if 0; # throws "Deprecated use of my() in false c +onditional" => 123 # my $y if shift; # no warning + => 112 print ++$y } tst(1); tst(); tst();

Anything that helps should be used...

Cheers Rolf

Replies are listed 'Best First'.
Re^4: A curious case of of my()
by JavaFan (Canon) on Apr 05, 2011 at 11:30 UTC
    As I pointed out in an earlier post, the warning is only for if 0; (or anything else that at compile time gets optimized away). It will not warn in the OPs case. Besides, there's no reason to assume the OP didn't use strict or warnings. And we shouldn't give the impressions people should post complete programs instead of relevant snippets showing the problem at hand. Which is what the OP did.