in reply to Re: Perl Inheritance Not Working as Expected
in thread Perl Inheritance Not Working as Expected

This error is just too easy to make. I used to use h2xs but it creates so much stuff that I avoid using it. I was at a Perl conference where one of the Stonehenge presenters used a 'new' tool to create classes but I forgot what it was.

h2xs -AXn Goo Defaulting to backwards compatibility with perl 5.40.1 If you intend this module to be compatible with earlier perl versions, + please specify a minimum perl version with the -b option. Writing Goo/lib/Goo.pm Writing Goo/Makefile.PL Writing Goo/README Writing Goo/t/Goo.t Writing Goo/Changes Writing Goo/MANIFEST joel@PLANTER1 goo]$

This does not create a 'new' boilerplate for you...

... our $VERSION = '0.01'; # Preloaded methods go here. ...

Other stuff but no 'new'. A new() method in the preferred fashion would be good, no?

Celebrate Intellectual Diversity

Replies are listed 'Best First'.
Re^3: Perl Inheritance Not Working as Expected
by hippo (Archbishop) on Apr 29, 2026 at 08:46 UTC
    Other stuff but no 'new'. A new() method in the preferred fashion would be good, no?

    No, because:

    1. Not every module is a class.
    2. Some (most?) modules which are classes use a framework which provides a standard new() in the superclass.

    If you only ever write OO modules and know that these will always have their own new() method then you can use one of the very many templating engines to write your own module creator to achieve this. I'm sure most of the existing new-project-creation tools have hooks for customisation too but I've never been bothered enough to go looking, TBH.


    🦛

Re^3: Perl Inheritance Not Working as Expected
by bliako (Abbot) on Apr 29, 2026 at 09:21 UTC

    I create OO modules manually. The boilerplate is minimal. FWIW, I use module-starter --module='XXX:XXX' --builder='ExtUtils::MakeMaker' --author='XXX' --email='XXX' to start a new module and never sought any alternative.