perl 异步超时 打印错误

#!/usr/bin/perl

use AnyEvent;
use AnyEvent::HTTP;


my $cv = AnyEvent->condvar;

sub doit{
    my $url = shift ;
    return if not defined $url;

    $cv->begin;
    http_get( "$url",timeout => 20, sub { done( $url, @_ ) } );
    print "1111111111111111
";
}

sub done {
    my ($url, $content, $hdr) = @_;

    $cv->end();
    print "Search: $url	Status: ", $hdr->{Status}, "
";
    if ($hdr->{Status}==200)
             {
             print "$content is $content
";
             }elsif
            ($hdr->{Status}==596){
             print "time out
";
            }}


&doit('http://120.55.118.6:3000/api/env?ip=192.168.32.101');
    print "222222222222222222
";
    print "3333333333333333333
";
$cv->recv();
~              

原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199731.html