use CPAN; for $mod (qw(Mail::Address)){ my $obj = CPAN::Shell->expand('Module',$mod); $obj->install; }