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


In reply to Re: Missing error under strict by Don Coyote
in thread Missing error under strict by Pascal666

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.