use CPAN; use strict; use warnings; $CPAN::Config = { 'build_cache' => q[10], 'build_dir' => q[/full/path/to/your/build/dir], # etc 'makepl_arg' => q[PREFIX=/full/path/to/wherever LIB=/full/path/to/lib/perl5 # etc ], # etc 'wget' => q[], }; $CPAN::Config_loaded = 1; my $mod = 'GD'; my $obj = CPAN::Shell->expand('Module',$mod); $obj->install;