locked_user sundialsvc4 has asked for the wisdom of the Perl Monks concerning the following question:
With perl 5.10.0, and, it would seem, with several other versions as well, I have just seen a case where the following construction did not cause a syntax error warning, even though use strict; use warnings; was being used: ($x and $y properly declared, no other use declarations, etc., blah blah blah, meh...)
if ($x eq my $y) ...
my, in this context, is of course an erroneous “bareword.” a situation that is syntactically legal but which should cause a warning (since I have expressly asked for them). But, why was the apparetn tpyo ( ;-} “apparent typo!”) not detected by Perl?
Also note that an equivalent perl -e 'blah...' one-liner did not reproduce the problem. (It flagged the bareword produced the warning (see reply in this thread).) The code file in question is many thousands of lines long, so I can’t practically include either it nor a segment.
So, kindly take for granted, that I know whereof I speak on what I am seeing here, and please help me with my initial response of, “WTF?!?!” I know that the my keyword can be used “inline” in many places, e.g. for[each](), but I am unaware of any legitimate place for it in an if() statement.
This humble Monk now penitently beseeches thee: Enlightenment?
| Replies are listed 'Best First'. | |
|---|---|
|
Re: My, what is "my" doing here?
by moritz (Cardinal) on Jan 27, 2012 at 13:05 UTC | |
|
Re: My, what is "my" doing here?
by Eliya (Vicar) on Jan 27, 2012 at 13:07 UTC | |
by locked_user sundialsvc4 (Abbot) on Jan 27, 2012 at 13:21 UTC | |
by JavaFan (Canon) on Jan 27, 2012 at 13:27 UTC | |
by choroba (Cardinal) on Jan 27, 2012 at 13:28 UTC | |
|
Re: My, what is "my" doing here?
by ikegami (Patriarch) on Jan 27, 2012 at 21:51 UTC | |
|
Re: My, what is "my" doing here?
by locked_user sundialsvc4 (Abbot) on Jan 27, 2012 at 13:16 UTC |