����Υǥ����ȤȤ��Ƽ꺢�ʥ�������������ä��Τǡ�
#!/usr/local/bin/perl # # $Id: lwp-callback-example.pl,v 0.1 2008/11/20 15:16:48 dankogai Exp dankogai $ # use strict; use warnings; use LWP::UserAgent; use File::Basename; my $uri = shift || die "$0 http://example.com/big.iso [filename]"; my $filename = shift || basename($uri); open my $wfh, '>', $filename or die "$filename:$!"; my $res = LWP::UserAgent->new->get( $uri, ':content_cb' => sub { my ( $chunk, $res, $proto ) = @_; print $wfh $chunk; my $size = tell $wfh; if (my $total = $res->header('Content-Length')){ printf "%d/%d (%f%%)\r", $size, $total, $size/$total*100; }else{ printf "%d/Unknown bytes\r", $size; } } ); close $wfh; print "\n", $res->status_line, "\n"; unlink $filename unless $res->is_success;
id:cho45���������äȤ����Ȥ��䤹�����Ƥߤޤ���(i.e. URI�򥳥ޥ�ɥ饤�󤫤���ʤ�)��
Enjoy!
Dan the Perl Monger
���Υ֥����˥����Ȥ���ˤ�����������ɬ�פǤ���
��������������
���ε����ˤϵ��ĥ桼�����������Ȥ��Ǥ��ޤ���