use Getopt::Long; sub restart_server { my( $host, $port, $timeout ); local @ARGV = @_; GetOptions( 'host=s' => \$host, 'port=i' => \$port, 'timeout=i' => \$timeout, ); # ... }