Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: While loop does not terminate

by nysus (Parson)
on Dec 13, 2020 at 18:31 UTC ( #11125130=note: print w/replies, xml ) Need Help??


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 (Sage) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11125130]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-10-20 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (81 votes). Check out past polls.

    Notices?