Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: It's the little things...

by Lady_Aleena (Chaplain)
on Apr 16, 2012 at 05:22 UTC ( #965240=note: print w/ replies, xml ) Need Help??


in reply to It's the little things...

Last Saturday I was rewriting a script and was getting sick of all of the ifs I was using. My code was to the point that I was 12 tabs down. Someone once said that about 4 was the maximum, so 12 was a bit much. Since I was in a for loop, I decided to finally see if I could get the hang of using next. OMG! The depth of my code got shallow rather quickly. I went from a depth of 12 tabs to 7. I felt a bit of joy at that point. I just wanted it share with you all how happy that little insight finally saved me from plunging too deep and having fewer brackets made it easier to find where I am when writing my script. Now I'm wondering how much unnecessary depth I have elsewhere. I think I will go spelunking.

Have a cookie and a very nice day!
Lady Aleena


Comment on Re: It's the little things...
Select or Download Code
Re^2: It's the little things...
by jdporter (Canon) on Apr 16, 2012 at 14:33 UTC

    Here's the next secret. You can get rid of just about all your nesting depth by replacing control structures (subroutines, for loops, etc.) with gotos. It's what you might call a higher level of wizardry, but it sounds like your nearly ready for it.

Re^2: It's the little things...
by Jenda (Abbot) on Apr 17, 2012 at 08:59 UTC

    Maybe you should consider moving some of the code into separate subroutines. If you are 7 tabs deep, your code is most likely also rather long. Extracting and naming bits of it might make things more maintainable.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (12)
As of 2014-04-17 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (444 votes), past polls