Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-19 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found