http://qs321.pair.com?node_id=11115648


in reply to Perl Best Practices - Loop Labels

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Perl Best Practices - Loop Labels
by haukex (Archbishop) on Apr 16, 2020 at 20:43 UTC
    To me, "loop labels are GOTOs." ... "Best practice?" Stomp them out!

    I realize I'm responding to a troll, but this is just way too wrong. Yes, one can write bad code in any language. But labels applied to loops and blocks are the solution to avoid gotos. Just one example, compare the code in this node to the one in my reply.

Re^2: Perl Best Practices - Loop Labels
by Your Mother (Archbishop) on Apr 16, 2020 at 20:17 UTC

    Maybe you could show some code demonstrating your point or clarify this, nothing is truly structural, everything executes, or show something, anything, worth reading. I am personally in accord with some of the best programmers at the monastery who already answered: loop labels can be nice, elucidating even, as long as they are only a couple—three would be my limit before biting the refactoring bullet—deep.

Re^2: Perl Best Practices - Loop Labels
by BillKSmith (Monsignor) on Apr 17, 2020 at 03:32 UTC
    If you find the deeply nested 'if blocks' usually needed to replace 'next' or 'last' are easier to maintain, use them - always! Personally, I strongly prefer 'next' and 'last'. The issue of labels is much less clear.
    Bill