Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: It's the little things...

by Lady_Aleena (Priest)
on Apr 16, 2012 at 05:22 UTC ( [id://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

Replies are listed 'Best First'.
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.

Re^2: It's the little things...
by jdporter (Paladin) 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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-20 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found