Perl Monk, Perl Meditation | |
PerlMonks |
Re^3: Code style advice: where to put "use" statements?by talexb (Chancellor) |
on Apr 14, 2021 at 13:26 UTC ( [id://11131275]=note: print w/replies, xml ) | Need Help?? |
Keep in mind that the layout of any source file is supposed to be useful for the reader. The compiler or interpreter doesn't care what it looks like. I worked with a sysadmin who was vision impaired, and didn't use any indentation, anywhere, ever. That worked for him, and bash didn't care. So here's how one of my typical scripts looks like: Other people use different hash bang lines, perhaps using env instead. Fine. I always put strict and warnings up there, and I fix whatever errors they highlight. I also put a comment block up there -- even writing down what I think I'm doing helps clarify what my goal is. And if it might help me in six months time, great. Then I get into the modules, and I list them in the same order I ordered my #include statements forty years ago when I was learning C -- I put the system ones first, and then my personal or local ones after that. Partly it's so that I'm reminded that my choices get higher priority than the system choices. I wrote some C code for a Perlmongers presentation on memory allocation recently, and one of the source files started like this: So I've got two system includes, followed by a local include. Anyway, work starts soon, so just to reiterate .. the source code layout is to assist the human. The computer doesn't care. I try hard to write in a style that's legible to me, and to other developers. I have pride in my work -- I want people to look at the code and have a good first impression.
In Section
Seekers of Perl Wisdom
|
|