We don't bite newbies here... much | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Finally can someone comment on the indentation? Does it make sense they way I did it? It looks less messy but no clue if I got the philosophy behind it. The philosophy is not tricky. Indentation is supposed to make the code easier to read by making it very obvious to the observer where each block of code and/or each statement starts and ends. This is particularly important when you end up with multi-line statements or a number of blocks which close at the same time. With that in mind, indenting by 1 space for each level will earn you very few friends. Even worse you have been inconsistent. Compare the indenting of the while loop which reads the file versus the following for loop which starts the processing - the former is less indented than the latter which is wrong and therefore misleading to anyone reading the code. Use 2 spaces for each indent at the bare minimum. The most widely used within perl modules appears to be 4 (among the code I've seen). Alternatively you can use tabs. This has the advantage that you can use one character (a tab) per indent and then anyone else viewing the code can simply set the tab width to whatever they prefer. The choice of tabs vs spaces is a highly personal one, however, so be aware that you won't please everyone (see No Hard Tabs in Code). Do not use tabs for alignment. Finally, until you understand what you are doing with indentation (and even then too), consider perltidy In reply to Re: how to get average of matrices' elements?
by hippo
|
|