in reply to use of last

Hello morgon,

It doesn’t work for me (Strawberry Perl running under Windows 8.1, 64-bit):

use strict; use warnings; my ($x, $y) = (1, 0); if ($x) { $y or last; print "Continue with the if clause\n"; } print "Do something else\n";

Output:

18:04 >perl 1312_SoPW.pl Can't "last" outside a loop block at 1312_SoPW.pl line 8. 18:04 >perl -v This is perl 5, version 22, subversion 0 (v5.22.0) built for MSWin32-x +64-multi-thread

I get the same result with next.

What version of Perl are you using?

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: use of last
by morgon (Priest) on Jul 20, 2015 at 08:23 UTC
    It is getting stranger...

    Your code does not work for me as well, however this does:

    use strict; use warnings; my ($x, $y) = (1, 0); if ($x =~ /whatever/) { $y or last; print "Continue with the if clause\n"; } print "Do something else\n";
    Probably in your case the optimizer is too smart ...

    I am using 5.18.1 on Debian.

    UPDATE: I was wrong. If you change the regex to !~ (so that the condition is true) you get the same error.