in reply to Re: Another reason for perl beginners to read perldocs
in thread Another reason for perl beginners to read perldocs

A good rule of thumb is, if you have 2 or more loops, you might use a label. You need a label if you want to exit an outer loop from an inner loop :)

Another good rule of thumb is, if you have 2 or more loops, start turning inner loops into function calls :)

  • Comment on Re^2: Another reason for perl beginners to read perldocs

Replies are listed 'Best First'.
Re^3: Another reason for perl beginners to read perldocs
by GrandFather (Saint) on Jul 03, 2011 at 00:12 UTC

    I would strengthen your first rule of thumb to: "You should only use a label if you have two or more nested loops and need to exit from an inner loop to an outer loop".

    I very much agree with your second rule except I would widen it to include any nested code: "If you have nested flow control blocks consider moving inner blocks into functions".

    True laziness is hard work