Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Get code ready for a loop (and a little RFC)

by GrandFather (Sage)
on Mar 13, 2020 at 07:57 UTC ( #11114207=note: print w/replies, xml ) Need Help??


in reply to Get code ready for a loop (and a little RFC)

Why not just put the code in a sub and call the sub inside the loop?

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
  • Comment on Re: Get code ready for a loop (and a little RFC)

Replies are listed 'Best First'.
Re^2: Get code ready for a loop (and a little RFC)
by Lady_Aleena (Curate) on Mar 13, 2020 at 08:12 UTC

    That would be a big sub, but it has crossed my mind. 8)

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena

      Better a big sub than a sea of code inside a loop. One advantage of using a sub is you get to name it so at the point where it is called the intent is clear. The point about big blobs of code is that you can't keep everything in your head while you try to understand what is going on. Breaking it up into named chunks (subs) makes the code easier to write correctly and easier to maintain.

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11114207]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2020-09-28 22:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (144 votes). Check out past polls.

    Notices?