my @CMDS = ("ps", "top", "df", "vmstat", "blah"); my @FILES = ( "/etc/running.cfg", "/home/me/lastchecked.txt", "/var/log/httpd/error_log"); my ($cmd, @ARGS) = split(/\s/, $input); my $ok; for(@CMDS) { if($cmd eq $_) { $ok=1; } } if(!$ok) { die "tried to do something that wasn't cool: $input\n"; } # then check for files in args my $ok=0; my $arg; foreach $arg (@ARGS) if(-e $arg) { # we have a file $file=true; for(@FILES) { if($arg eq $_) { $ok=1; } } } } if($file && !$ok) { die "tried to access a bad thing: $input\n"; } # We're pretty much safe to continue