How do you use Module::Build vs ExtUtils::MakeMaker with a short example?

Learn how to use Module::Build and ExtUtils::MakeMaker in Perl to create and manage your Perl module distributions effectively.
Module::Build, ExtUtils::MakeMaker, Perl, module distribution, Perl modules

# Using ExtUtils::MakeMaker
use ExtUtils::MakeMaker;

WriteMakefile(
    NAME         => 'My::Module',
    VERSION_FROM => 'lib/My/Module.pm',  # finds $VERSION
    PREREQ_PM    => { 'Some::Module' => 0.01 },  # module prerequisites
);

# Using Module::Build
use Module::Build;

my $build = Module::Build->new(
    module_name => 'My::Module',
    module_version => '0.01',
    license => 'perl',
    requires => {
        'Some::Module' => '0.01',  # module prerequisites
    },
);

$build->create_build_script;
    

Module::Build ExtUtils::MakeMaker Perl module distribution Perl modules