opendir( DIR, $command-directory ) || die "cant open dir: $!"; @commands = readdir( DIR ); @commands = grep( m!\.pm$!, @commands ); # only .pm files $torun = "thetime"; $arg1 = '.....'; $arg2 = 'etc.'; foreach ( @commands ) { if( $_ eq $torun ){ $continue = 'true' } else{ $continue = undef } } if( defined( $continue ) ) { require ("$torun" . "\.pm"); ${$torun}::{$torun}->( $arg1, $arg2 ); # run subroutine $torun in file $torun.pm } if( !defined( $continue ) ) { print "no such method call: $torun\n"; }