#! /usr/bin/perl

use strict;
use warnings;
use WWW::Curl::Easy;
use WWW::Curl::Multi;


    my $curl=WWW::Curl::Easy->new;
    my $multi=WWW::Curl::Multi->new;
    $curl->setopt(CURLOPT_VERBOSE, 1);
    $curl->setopt(CURLOPT_URL, 'ftp://ftp.uk.debian.org/debian/dists/stable/Release.gpg');
    $curl->setopt(CURLOPT_FTPPORT, '-');
    open my $fh, ">/dev/tty"||die $!;
    $curl->setopt(CURLOPT_WRITEHEADER, $fh);
    $curl->setopt(CURLOPT_HEADERFUNCTION, \&callback);
    sub  callback {
	my ($chunk,$fh)=@_;
	print $fh $chunk;
	return length($chunk);
    }

    $multi->add_handle($curl);

    while ($multi->perform){};

    close $fh;

while (1) {
}

