The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl

use strict;
use warnings;

use 5.010001;

use autodie;
use File::Spec;
use File::Fetch;

$File::Fetch::BLACKLIST = [ qw/lwp/ ];

my $home   = File::Spec->catdir(  $ENV{HOME}, '.enbld'  );
my $cpanm  = File::Spec->catfile( $home, 'etc', 'cpanm' );
my $extlib = File::Spec->catdir(  $home, 'extlib'       );

clear_MYMETA();
download_cpanm() unless ( -e $cpanm );

say "=====> Install Enbld to $home.";

system( '/usr/bin/perl', $cpanm, '-L', $extlib, '.' );

print << 'EOF';
=====> Finish installation.

Please add following path to PATH.

    $HOME/.enbld/extlib/bin
    $HOME/.enbld/bin
    $HOME/.enbld/sbin

Please add following path to MANPATH.

    $HOME/.enbld/share/man
    $HOME/.enbld/man

EOF

sub download_cpanm {
    my $ff       = File::Fetch->new( uri => 'http://xrl.us/cpanm' );
    my $location = File::Spec->catdir( $ENV{HOME}, '.enbld', 'etc' );
    my $where    = $ff->fetch( to => $location ) or die $ff->error;
}

sub clear_MYMETA {
    unlink( 'MYMETA.json' ) if ( -e 'MYMETA.json' );
    unlink( 'MYMETA.yml'  ) if ( -e 'MYMETA.yml'  );

}