#!/usr/bin/perl -w # $module is the module you're checking for $module = "DBI"; eval("require $module") ? &run() : &runwithout; sub run { print "Installed\n"; use DBI; } sub runwithout { print "Not Installed\n"; }