in reply to Missing error under strict

Hello Pascal666

The until BLOCK enters a new lexical scope. When used in BLOCK form. When used as a statement modifier the scope has not entered into a BLOCK. The lexical scope is at the file level so there is no need for strict to complain.

I was going to suggest using the feature state but this does not change the problem. It does however allow scoping to take place within the block

Variables lexically scoped with my will be initialised, then get undefined when leaving the scope. As the scope is the body of a loop this re-occurs each iteration

Variables lexically scoped with state will be initialsed but with enough mana to last till the scope exits at the completion of the loop, whence they will meet their timely fate.

Change the state and my declarations in the following code, but if you use both my, make sure to uncomment the last three lines of the loop.

use strict; use warnings; use feature qw'say state'; until ( (state $two = 2)[0] == 2*2*2 ) { state $four = 16; last unless $four; say --$four =~ /\d{2}/ ? "$four" : '0'.$four, ': ',$two++ ; # my my ? uncomment # state $FOUR=64; # $FOUR >= 48 and print '$FOUR: ',$FOUR; # last unless $FOUR--; } say 'owt: ',my $two=2;

Edited main scope to say file scope, re LanX

Replies are listed 'Best First'.
Re^2: Missing error under strict
by LanX (Saint) on Jul 23, 2019 at 15:03 UTC
    > The lexical scope is still main so there is no need for strict to complain.

    what do you mean with lexical scope "main"?

    If you mean the package main:: , there is nothing like a lexical scope there, packages are global.

    In this case it's the file scope.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice