… | |
… | |
22 | print "$user\@$host: $_" while <$fh>; |
22 | print "$user\@$host: $_" while <$fh>; |
23 | print "$user\@$host: done\n"; |
23 | print "$user\@$host: done\n"; |
24 | } |
24 | } |
25 | |
25 | |
26 | # display the time or garble the display, YMMV. |
26 | # display the time or garble the display, YMMV. |
27 | sub timer : Coro { |
27 | async { |
28 | my $w = Coro::Event->timer (interval => 0.001, hard => 1); |
28 | my $w = Coro::Event->timer (interval => 0.001, hard => 1); |
29 | use Time::HiRes qw(time); |
29 | use Time::HiRes qw(time); |
30 | while () { |
30 | while () { |
31 | $w->next; |
31 | $w->next; |
32 | print "\e7\e[C\e[C\e[C\e[C\e[C\e[C\e[C\e[C <time ", time, "> \e8"; |
32 | print "\e7\e[C\e[C\e[C\e[C\e[C\e[C\e[C\e[C <time ", time, "> \e8"; |
33 | }; |
33 | }; |
34 | } |
34 | }; |
35 | |
35 | |
36 | my $stdin = new_from_fh Coro::Handle \*STDIN; |
36 | my $stdin = new_from_fh Coro::Handle \*STDIN; |
37 | |
37 | |
38 | $SIG{PIPE} = 'IGNORE'; |
38 | $SIG{PIPE} = 'IGNORE'; |
39 | |
39 | |
… | |
… | |
43 | if ($cmd eq "finger") { |
43 | if ($cmd eq "finger") { |
44 | print "user> "; my $user = <$stdin>; chomp $user; |
44 | print "user> "; my $user = <$stdin>; chomp $user; |
45 | print "host> "; my $host = <$stdin>; chomp $host; |
45 | print "host> "; my $host = <$stdin>; chomp $host; |
46 | async { finger $user, $host }; |
46 | async { finger $user, $host }; |
47 | } elsif ($cmd eq "quit") { |
47 | } elsif ($cmd eq "quit") { |
48 | $quit->send; |
48 | last; |
49 | } else { |
49 | } else { |
50 | print "unknown command '$cmd', either 'finger' or 'quit'\n"; |
50 | print "unknown command '$cmd', either 'finger' or 'quit'\n"; |
51 | } |
51 | } |
52 | } |
52 | } |
53 | |
53 | |