in reply to Wierd bugs I would have never expected

A module had the line return 1 outside of a sub.

It's pretty normal for a module to have return 1 outside of a sub. Are you sure that's the cause of the problem you saw?

What is the sound of Windows? Is it not the sound of a wall upon which people have smashed their heads... all the way through?

Replies are listed 'Best First'.
Re^2: Wierd bugs I would have never expected
by ELISHEVA (Prior) on Dec 16, 2010 at 14:48 UTC

    At least as near as I can possibly see. It wouldn't be the first time I thought A was the issue when in fact B was. But I'm fairly certain. I narrowed it down by the old comment out code until nothing is left but the bare minimum to recreate the bug. The sample is pretty slim.

    There are in fact two possible ways to make the bug go away. (a) add a printf within the sub that wants to use the $SOME_CLASS or (b) comment out the return 1. Plain old 1; ( no return) at the end of the file works fine. It is only when the word return is added. I'm not inclined to blame the bug on failing to have a printf in the sub since that doesn't seem to me to be a reasonable requirement of proper use of package my variables.

    Here is the code that shows the problem. The test script:

    use strict; use warnings; use Monks::Foo::ReturnInModule; weAreOffToSeeTheWizard();

    The module Monks/Foo/ReturnInModule.pm:

      I can't replicate the issue with v5.10.x and v5.12.2 (while I can with an old 5.8.4). So, maybe it was a bug that's been fixed in the meantime... (?)

        Thanks for checking that. I somewhat suspected that it was a Perl bug that was likely fixed in a later edition which is why I included the version number in the bug description in the original post. I don't have a set up where it is easy to test a script against multiple versions so I especially appreciate your feedback.