Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Missing error under strict (Perlbug: postfix 'until' has inconsistent scope)

by Don Coyote (Hermit)
on Jul 23, 2019 at 14:37 UTC ( [id://11103223]=note: print w/replies, xml ) Need Help??


in reply to Re: Missing error under strict (Perlbug: postfix 'until' has inconsistent scope)
in thread Missing error under strict

state declaration, holds

use strict; use warnings; use feature qw'say state'; {no strict; no warnings; $three = 1; say 'three' until $three++ == 3; } #Use of uninitialized value $two in say at SoPW_11103184.pm line 54 say 'two' until my $two = 2; #say 'owt',$two; say 'one' until state $one = 1; say 'eno',$one; {no strict; no warnings; say $zero until $zero = 9; } say our $minone = 5 until $minone = 8; say $minone; # says '5' continuously #say our $mintwo = 5 until 3 == $mintwo--; #say $mintwo; __END__ three three #say $two #uninit warning eno1 8

Depending how the scope is declared determines if the assignment is fully evaluated


Can't find method 'say' in Module 'Died at ....' at ...
  • Comment on Re^2: Missing error under strict (Perlbug: postfix 'until' has inconsistent scope)
  • Download Code

Replies are listed 'Best First'.
Re^3: Missing error under strict (Perlbug: postfix 'until' has inconsistent scope)
by LanX (Saint) on Jul 23, 2019 at 14:42 UTC
    state is a much higher level of headaches and AFAIR not reliable.

    the ... until XXX $var = "x" with XXX a possible declaration is always executed.

    It just happens that $var is reset afterwards.

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

      I think I see the issue now

      Basically my and state should be in the same scope, but state just holds value through iterations. So the my declaration should hold after the until modifer is executed, as it does with the state declaration.

      I'm kind of wondering if 'our' gets restricted to what 'my' should do by this behaviour

      First time I thought of using our to declare lexicality while using the same variable more than once in an expression.

        Our works as expected, which is another argument for my theory that the loop's "scope" is falsely cleaned.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11103223]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-04-25 15:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found