use WWW::Curl::Easy;
use Data::Dumper;
my %opts = (
CURLOPT_URL => 'http://wikipedia.org',
CURLOPT_CONNECTTIMEOUT => 30
);
sub curl_func {
my ($curlOptions) = @_;
my $ch = new WWW::Curl::Easy();
while (my ($key, $value) = each %$curlOptions) {
$ch->setopt($key, $value);
}
# ....
}
curl_func(\%opts);
use WWW::Curl;
use WWW::Curl::Easy;
use Data::Dumper;
my %opts = (
CURLOPT_URL => 'http://wikipedia.org',
CURLOPT_CONNECTTIMEOUT => 30
);
sub curl_func {
my ($curlOptions) = @_;
my $ch = new WWW::Curl::Easy();
while (my ($key, $value) = each %$curlOptions) {
$ch->setopt(&{$key}(), $value);
}
# ...
}
curl_func(\%opts);