in reply to Re^2: Radoteur
in thread Radoteur

Your loop labels are not required here (and rarely ever are). You can remove them in both the loops, and the last and next calls. For example, replace:

WORD_ITER:foreach(...)

with:

foreach(...)

and:

next WORD_ITER; last WORD_ITER;

with just:

next; last;

You can do this in both your while and for statements/blocks.

Replies are listed 'Best First'.
Re^4: Radoteur
by QuillMeantTen (Friar) on Oct 20, 2015 at 08:57 UTC

    I know they are not needed, yet I read in Perl Best Practices that whenever last or next are used adding labels helps will the readability and future maintanability of the code

    It seemed to make sense so I adopted the practice. update: typo

      I read in Perl Best Practices that whenever last or next are used adding labels helps will the readability

      If you are prepared to pay a 15% performance penalty for that asinine piece of advice; continue:

      cmpthese -1,{ a=>q[ LOOP:for(1..1000){ next LOOP; } ], b=>q[ for(1..1000){ next; } ] };; Rate a b a 7862/s -- -14% b 9195/s 17% --

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.

        In simple and obvious code I agree, but right now I am trying to educate myself so I can work on intricate code without making a mess.
        You are entitled to your opinion concerning this practice. I feel that sometimes sacrificing some performance to ease of maintenance might be the way to go

        Yeah, in the code I posted it isnt useful, the loops are quite obvious and so are the concepts behind the algorithm. I'll agree with you that it is a waste of ressources and the same effect could be obtained with comments.
        Please bear in mind that I am not as experienced as you are and as I learn I try and apply what I consider to be best practices everywhere so I naturally start thinking that way first before choosing performance over readability.