in reply to do-while loop never exits

$test is out of scope when your code reaches line 8; hence, $test is always ne "quit."

One way around that is to declare my $test" at (an inserted) line 2 and remove the "my" at line 5; there are other alternatives to making $test global (which is generally a bad idea).

In any case, in earlier versions of Perl, use strict; use warnings would have alerted you to this problem; since it didn't (or, "Naughty, naughty! You didn't tell us about a message on the order of 'Global symbol "$test" requires explicit package name at ....'"), I'm going to have to recheck my (mis-?) understanding that 5.12 would invoke strict unless overridden see below.

Update: Credit Corion who offered the necessary correction to my misunderstanding:

"...the implicit strictures come from use 5.12;"

brian d foy posted (to http://www.effectiveperlprogramming.com/blog/468) on the subject:

"Perl 5.12 can turn on strict for you automatically, stealing a feature from Modern::Perl that takes away one line of boilerplate in your Perl programs and modules. We talk about strict in Item 3: Enable strictures to promote better coding. Similar to what we show in Item 2: Enable new Perl features when you need them, to turn strictures on automatically, you have to use use with a version of Perl 5.11.0 or later:

    use 5.012;

This is really just the same thing as explicitly turning on strict and importing the 5.12 feature bundle:

use strict; use feature ':5.12';

Note that this means merely importing the feature bundle does not include this implicit strictures benefit. Don’t think you’re safe merely because you are using a perl5.12 interpreter.

Replies are listed 'Best First'.
Re^2: do-while loop never exits
by toolic (Bishop) on Apr 19, 2011 at 13:30 UTC