http://qs321.pair.com?node_id=11125130


in reply to While loop does not terminate

The root cause of the problem was that I moved the get_value() function to another package where it did not have access to a variable it needed to work properly. So it was returning unexpected results.

The root cause of that problem was no tests to catch the problem.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^2: While loop does not terminate
by marto (Cardinal) on Dec 13, 2020 at 18:33 UTC
Re^2: While loop does not terminate
by LanX (Saint) on Dec 13, 2020 at 20:22 UTC
    > that I moved the get_value() function to another package where it did not have access to a variable it needed to work properly.

    how is this possible to happen silently under strict???

    DB<232> use strict;use warnings; print $XXX lobal symbol "$XXX" requires explicit package name (did you forget to declare "my $XXX"?) at (eval 263) [c:/Perl_524/lib/perl5db.pl:737] line 2.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      Strictures don't bleed through to included packages. Consider:

      # noname.pl: use warnings; use strict; use lib '.'; use noname1; print noname1::get_value(); # noname1.pm: package noname1; sub get_value { return $missingVar // 'Bogus value'; } 1;

      Prints:

      Bogus value
      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
        I supposed it's obvious that strictures must be used in each file, since pragmas are scoped.

        # noname1.pm: use strict; use warnings; package noname1; sub get_value { return $missingVar // 'Bogus value'; } 1;

        now running ...

        # noname.pl: use warnings; use strict; use lib '.'; use noname1; print noname1::get_value();

        output

        Compilation started at Sun Dec 13 22:16:46 C:/Perl_524/bin\perl.exe -w d:/tmp/pm/noname_strictures/noname.pl Global symbol "$missingVar" requires explicit package name (did you fo +rget to declare "my $missingVar"?) at noname1.pm line 9. Compilation failed in require at d:/tmp/pm/noname_strictures/noname.pl + line 6. BEGIN failed--compilation aborted at d:/tmp/pm/noname_strictures/nonam +e.pl line 6. Compilation exited abnormally with code 255 at Sun Dec 13 22:16:46

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery