in reply to Re: efficient use of subroutines
in thread efficient use of subroutines

Thanks to everyone for all your comments. Seems like I had it backwards in terms of readability vs efficiency. I will take the advice of the majority and make more subroutines.

Replies are listed 'Best First'.
Re^3: efficient use of subroutines
by 5plit_func (Beadle) on Feb 05, 2015 at 23:19 UTC

    In my own view. Subroutines i create for my programs do one thing and do it well. Let the names of your subroutine tell you more about what lies within it and its ultimate function. e.g sub display_data().

    Learn to reduce the length of you subroutines try to make them compact and straight to the point. things like first naming your variables before assigning values to them are way too long and repetitive. e.g my $name = undef; $name = qq{liray}
    could be reduced to my $name = qq{liray};

    Finally clarity, maintenance should be kept in mind, because you could visit this subroutine 6 months down the line and begin to wonder what you created it to do and why. Also learn to express your self in the best possible way that suits your style of programming.