in reply to Re: While loop does not terminate
in thread While loop does not terminate

> 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

Replies are listed 'Best First'.
Re^3: While loop does not terminate
by GrandFather (Saint) on Dec 13, 2020 at 20:47 UTC

    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