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:

#!/usr/bin/perl use v5.12; use warnings;

(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".

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

In reply to Re: Starting a New Script by afoken
in thread Starting a New Script by LloydRice

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.