Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Style & subroutine organization

by HamNRye (Monk)
on Aug 30, 2001 at 00:07 UTC ( #108872=note: print w/replies, xml ) Need Help??

in reply to Style & subroutine organization

I do not maintain that this is the best way to do it, it's just my way....

I like to think of my subroutines in terms of giving instructions.

@lines = &readFile ; @output = &parseLines(@lines) ; &doReport(@output) ;

The reason I use this method is for readability. Read the file to get the lines, parse the lines to get the output, use the output to do the report. It allows me to quickly find the errant code block if there is a problem, and in the design phase I am left with a good outline to build my program around.

Now, on to questions of efficiency, mem footprint, etc... I don't really care. According to my boss, all of the servers work fast enough and I don't. Hence, my main goal is to speed up my work. Also, in a modern computer you should have better than 64MB of RAM, and the space taken up by some of the extra arrays is totally negligible.

Also, look at this write up by Merlyn on references. Passing references to subs will simplify your life at some point.

To redo your example my way:

$f1 = func1(); $f2 = func2($f1); $f3 = func3($f2); print $f3; (or) print func3($f2);
Hope it helps... ~Hammy

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2020-09-24 02:42 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (132 votes). Check out past polls.