Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • If I get it right the faulty statement was something like: my $var = 'passed' if cond();, right? This looks really strange and funny to me. I understand it as execute this statement (which declares a variable) only if the condition is true. If the condition is false then the statement shouldn't be executed, thus no creation of variable. That's not what Perl might do as I'm expecting Jozef to be using "strict" and his module might have not compiled otherwise avoiding this peculiar situation. You where using strict right?

    What I don't understand is how the variable could have been reset to it's previous value? Unless if the variable was a global variable this shouldn't happen. Perl is supposed to destroy all lexical variables after the end of the block. How can Perl manage to preserve the value?

    • It generally keeps the “pad” (the allocation space for lexicals, basically) around. Sometimes, eg. for recursive calls, it will allocate extra pads that may be garbage-collected later. So this faux-feature actually doesn’t work reliably except in the simplest use cases. It’s a good thing that 5.10 deprecates it and 5.12 will probably throw an error for such usages.