foreach (@commands) { my ( $command, @args ) = @$_; warn("Naughty, $command not allowed..."), next unless $permitted{$command}; warn("Ooops, I can't find $command..."), next unless $g->can($command); $g->$command( @args ); }