Hi Stephen,
"Stephen Clouse" <[EMAIL PROTECTED]> wrote ...
> ...I did manage to figure out the issue today. You may or may not be
> surprised to find it was this:
>
> my $foo = "bar" if $baz;
Yikes! My bad :-) It must've been a different scary memory error that I
encountered with List::Util.
> Apparently one of the previous programmers left about 100 such constructs
> littered about the Perl and Mason code. Fixing them cleared up all the
> bizarre issues.
I too was "one of those guys" who liberally littered his code with the
construct:
my $foo = 'bar' if $baz;
I unlearned to do it too, a few months back, which must have been why your
errors "rang a bell" with me. My co-workers had to track down that is was
my {declaration + assignment + conditional} that was throwing the scary
memory errors. I never saw it. I'd been doing it for years, and prior to
that I had no idea it was A Bad Thing to do, and I said as much to them,
"it's always worked fine for me!"
I wish it would still DWIM, and by that I mean the compiler should detect
my declaration + assignment + conditional and rewrite it for me as what I
meant which was simply:
my $foo = $baz ? 'bar' : undef;
That's how I've been rewriting these since then.
It seems a no-brainer that when no-brain people like me write this, they
mean to make the assignment conditional, not declaration of the variable,
so that:
declaration + assignment + conditional == declaration + (conditional
assignment)
I've already (finally) unlearned to do that, but I agree with Andy that the
cost of people's ignorance (especially doing something that's worked as
expected for so long) shouln't cause "rampant memory corruption". It
should maybe DWIM or die or warn, but not dump core :-)
-dave