Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: array code interpretation

by AnomalousMonk (Chancellor)
on Apr 10, 2013 at 06:44 UTC ( #1027899=note: print w/replies, xml ) Need Help??

in reply to Re: array code interpretation
in thread array code interpretation

I would quarrel with a couple of steps.

3. Storing the current line in '@array'.

The current line read from the file handle is completely ignored in the code given in the OP (which I admit is probably cut down from some real code). Instead, an element is 'popped' from the front of @array, i.e., its element 0 is removed (see shift), and this element is discarded.

4. Checking if array's first element is true.
4.1. If so, then exiting the block.

The block is exited via last unless element 0 of @array is true, i.e., if it is false. The pitfall of interpreting such double-negativity is a good reason to avoid conditionals based on unless, unless, IMHO, they are dead simple and in the statement modifier form:
    last LINE unless some_condition();
See  unless in Compound Statements and Statement Modifiers in perldoc perlsyn.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1027899]
[choroba]: I wouldn't want to maintain it in the current form
[erix]: ok, but mainainability comes after it has been made to work :)
[erix]: maybe I should have cobbled together a more simple example
[erix]: the main question is whether repeating groups get captured. I thought they did but it looks they do not.
[erix]: or they probably get overwritten when the repeating is done

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2018-01-19 08:36 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (216 votes). Check out past polls.