Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by Pascal666 (Scribe)
on Jul 24, 2019 at 01:31 UTC ( [id://11103266]=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

> I boiled the problem down to this code

Here you are initializing a seperate variable before the until, which is getting reset by the my inside the until. In my code I was initializing the variable inside the until, and then attempting to use it after. Seems like two different (but related) bugs to me.

> PS: I have problem to imagine practical code, where this bug is posing a problem.

My original code:

$count++ until my %boxes = fit($count, $quota, @sizes);
I wasn't sure about the scope when I wrote that line, but figured worst case I would get a compile error and move the my to the line above. Had a hell of a time figuring out why %boxes was always null when I tried to access it later (it should loop until %boxes is not null).
  • 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 24, 2019 at 07:30 UTC
    My intention was to proof a bug in short code.

    There is no possible explanation for an undefined value after the loop. Hence a bug.

    > Here you are initializing a seperate variable before the until, which is getting reset by the my inside the until.

    This statement doesn't really make sense, if the variables are different they can't reset each other.

    As already explained does my have a compile time and a runtime effect, which are inconsistent in this case.

    > Seems like two different (but related) bugs to me.

    No. Everything else was explained.

    > My original code:

    > $count++ until my %boxes = fit($count, $quota, @sizes);

    Thanks, nice example.

    FWIW a workaround is to put the my declaration right before the loop.

    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://11103266]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found