|XP is just a number|
Re: Starting a New Scriptby afoken (Chancellor)
|on Sep 16, 2016 at 18:48 UTC||Need Help??|
How do you start a new script? Do you just open a blank editor page and start typing?
Yes, exactly that. I usually start with this:
(In the old days, I used strict instead of v5.12, but now all machines that I use have at least perl 5.12 installed. Modules start with package Some::Package::Name instead of the shebang line.)
From there on, everything depends very much on what kind of script / module I write and for what purpose I write it. Automating those three lines of code is a waste of time, simply because even those three lines may vary.
I'm no big fan of generating tons of boilerplate code. If a system - especially in an OOP environment - needs hundreds lines of code just for a hello world program to work, something has gone horribly wrong in the early stages of the system.
Loading your top 1000 modules in every script just because you could need one of them during the lifetime of one of your scripts looks as insane as the boilerplate aproach to me.
Furthermore, every coder (except for the snake lovers) has his/her own preferences of how code should be structured, ordered and indented. The same is true for projects and companies, and of course, all preferences are different. So any code generator you could write either generates code using "the wrong style" or has a phantastillion of options allowing to configure any option, including the most insane ones. Naturally, you need to support at least a hundred different configuration mechanisms to fit all needs.
During my professional carreer, I saw and used very different methods for creating new source code. "Do as I say (don't do as I do)", "Do what ever you want to solve the problem", "Use the only style that works", "Copy the templates and fill in your code, following the coding guidelines written on those two pages", "Copy some old code and modify it until it works", and of course "Follow this simple 350 page instruction manual to create a skeleton for a hello world program".
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)