내 스크립트에서 다운로드 URL을 묻고 다운로드 대기열로 보냅니다. 다운로드 진행률이 인쇄되어야합니다.Perl print line over 프롬프트
프롬프트를 맨 아래에 유지하고 상태를 확인하는 방법을 찾지 못했습니다. CPAN에서 검색을 시도했지만 모듈이 없습니다.
도움 주셔서 감사합니다.
#!/usr/bin/perl
use 5.14.0;
use strict;
use warnings;
use Term::UI;
use Term::ReadLine;
use threads;
use Thread::Queue;
sub rndStr{ join'', @_[ map{ rand @_ } 1 .. shift ] }
my $q = Thread::Queue->new(); # A new empty queue
my $thr = threads->create(
sub {
while (defined(my $item = $q->dequeue())) {
say "Downloading: ".$item;
sleep 1;
#$q->enqueue(1..10) if $item eq '10';
$q->enqueue(rndStr rand (15)+5, 'a'..'z', 0..9);
}
}
);
$q->enqueue(rndStr 10, 'a'..'z', 0..9);
my $url;
my $term = Term::ReadLine->new('brand');
while ($url ne 'end'){
$url = $term->get_reply(
prompt => 'URL to download',
default => 'end');
$q->enqueue($url);
}
say "Finishing remaining downloads";
$q->enqueue(undef);
$thr->join();
당신은 가능성이 "저주"모듈을 찾고 있습니다 - https://metacpan.org/search?q=Curses – amon
Windows 시스템에서 "Curses"가 Win ([Bug] (https://rt.cpan.org/Public/Bug/Display.html?id=47785))과 작동하지 않습니다. 나는 그것을 내 시스템에 설치할 수 없다. – Lebewesen