#!/usr/bin/perl # this crap is an asynchroneous finger client. it's rather idiotic ;) use Coro; use Coro::Event; use Coro::Socket; # this gets started everytime a user enters a finger command sub finger { my $user = shift; my $host = shift; my $fh = new_inet Coro::Socket PeerHost => $host, PeerPort => "finger" or die; print $fh "$user\n"; print "$user\@$host: $_" while <$fh>; print "$user\@$host: done\n"; } my $stdin = new_from_fh Coro::Handle \*STDIN; # this is the main task sub keyboard : Coro { $|=1; while() { print "cmd> "; my $cmd = <$stdin>; chomp $cmd; if ($cmd eq "finger") { print "user> "; my $user = <$stdin>; chomp $user; print "host> "; my $host = <$stdin>; chomp $host; async { finger($user, $host) }; } elsif ($cmd eq "quit") { unloop(777); terminate; } else { print "unknown command '$cmd', either 'finger' or 'quit'\n"; } } } # display the time or garble the display, YMMV. sub timer : Coro { my $w = Coro::Event->timer(interval => 0.001, hard => 1); use Time::HiRes qw(time); while () { $w->next; print "\e7\e[C\e[C\e[C\e[C\e[C\e[C\e[C\e[C