in reply to Re^3: RFC: How to succeed with your Perl homework
in thread RFC: How to succeed with your Perl homework

I'm with Tux. First of all, one doesn't need any boilerplate to write "Hello world" in Perl.

Second, there isn't much difference in effort to write the three line boiler plate:

#!/usr/bin/perl use strict; use warnings;
instead of two lines:
#!/usr/bin/perl use Modern::Perl; # Or whatever todays fad boilerplate is
The savings of not typing a single line of code doesn't out weight the issues Tux mentions.

Now one may argue "but my 'use Shiny::Boilerplate;' includes a whole shit load of additional modules", but that only makes your boilerplate less generic. Because for each additional module/pragma in your boilerplate, a significant (probably > 50%) part of my programs/modules doesn't need it.

Replies are listed 'Best First'.
Re^5: RFC: How to succeed with your Perl homework
by chromatic (Archbishop) on Nov 04, 2010 at 16:47 UTC
    Second, there isn't much difference in effort to write the three line boiler plate:

    It's not effort to write; it's effort to explain and to understand.

    If you want to write your own book where you tell novices "Include these three to seven magic lines at the start of every program you write, but don't worry if you don't understand them, they're really important, trust me, and yes I meant every program you write!" be my guest. My goal was teaching Perl novices to write code somewhat better than they could with Perl 4 (and not to clutter every piece of code where I happened to use say or given/when or state with use 5.010; or use 5.012;).

      If you want to write your own book where you tell novices "Include these three to seven magic lines at the start of every program you write, but don't worry if you don't understand them, they're really important, trust me, and yes I meant every program you write!"
      You must misunderstand me.

      If I say my boilerplate is:

      #!/usr/bin/perl use strict; use warnings;
      I don't intend to write that as:
      #!/usr/bin/perl use strict ; use warnings ;
      Three lines is just 3 lines. Not 7.

      As for explaining, I rather explain the benefits of "use strict" and "use warnings" then "oh, just download this magical thingy from the internet, written by some dude, who will tell you just to trust him and use the magical thingy everywhere".

      In my years as a trainer, I never explained things away with "oh, this is just a magical thing which I won't explain, just trust me, use it". I'm not that lousy.

        You must misunderstand me.

        I counted the boilerplate I regularly use in my code. It's at least three lines and often as much as seven, after enabling strict, warnings, 5.10 syntax extensions, autodie, utf8, mro, and a couple of other pragmas.

        As for explaining, I rather explain the benefits of "use strict" and "use warnings"...

        As the first thing you do when teaching people how to write "Hello, world!" in Perl?