#line 1 "inc/Module/Install/PERSONAL/only.pm - /Users/ingy/lib/Module/Install/PERSONAL/only.pm" package Module::Install::PERSONAL::only; use Module::Install::Base; @ISA = qw(Module::Install::Base); use strict; use lib 't'; use Config; use File::Spec; use File::Path; use ExtUtils::MakeMaker qw(prompt); my $versionlib = ''; my $old_versionlib = ''; my $suggested_versionlib = ''; my $old_differs = ''; sub create_config_module { my $a; _heuristics(); $old_differs = ($old_versionlib and $old_versionlib ne $suggested_versionlib); _intro(); my $default = $old_differs ? 'n' : 'y'; while (1) { $a = prompt('Do you want to use the "suggested" directory (y/n)?', $default ); last if $a =~ /^[yn]$/i; } if ($a =~ /^y$/) { $versionlib = $suggested_versionlib; } elsif ($old_differs) { while (1) { $a = prompt('Do you want to use the "old" directory (y/n)?', 'y' ); last if $a =~ /^[yn]$/i; } if ($a =~ /^y$/) { $versionlib = $old_versionlib; } } _ask() if $a =~ /^n$/i; _write_template('config.pm.template', 'lib/only/config.pm', {VERSIONLIB => $versionlib}, ); } sub _heuristics { eval q{ require only::config }; unless ($@ or defined $only::config::versionarch) { $old_versionlib = &only::config::versionlib; } my ($vol, $dir) = File::Spec->splitpath( $Config{sitelib}, 1 ); my @dir = File::Spec->splitdir($dir); if (grep /^site/i, @dir) { s/^site.*/version/i for @dir; $suggested_versionlib = File::Spec->catpath( $vol, File::Spec->catdir(@dir), ); } else { $suggested_versionlib = File::Spec->catpath( $vol, File::Spec->catdir(@dir, 'version-lib'), ); } } sub _intro { print <file_name_is_absolute($a); } $versionlib = $a; } sub _write_template { my ($template_path, $target_path, $lookup) = @_; open TEMPLATE, $template_path or die "Can't open $template_path for input:\n$!\n"; my $template = do {local $/;