# at this point consider adding all your parameters into a hash and
# pass that to http_tiny($options) instead of passing a long list which
# may contain optional parameters.
my %h;
$h{infile} = $infile;
...
####
my %h; # or %params
...
Getopt::Long::GetOptions(
'infile=s' => \$h{infile},
# or more flexible:
'outfile=s' => sub { $h{$_[0]} = $_[1] },
# the anonymous sub above will be called with 2 params
# when --outfile is detected: the key (outfile) and its value
...
}
####
sub get_... {
if( /error/ ){ print STDERR "errors"; return undef }
return [$url, $key];
}
# use it
my $ret = get_...();
if( ! defined $ret ){ print STDERR "call to get_...() has failed"; exit(1) }
my ($url, $key) = @$ret;