use strict; use warnings; use Getopt::Long; my %options; GetOptions(\%options, 'fetch', 'user=s', 'password=s'); if (exists $options{fetch}) { fetch (%options); } sub fetch { my %options = @_; print "$options{password} $options{user}\n"; }