I wrote this to get some exposure with sockets, and it turned out to have some value as a regex's exercise too. I don't know if anyone else will find this useful, but for me, its a cool use for perl!
#!/usr/bin/perl use strict; use Socket; my $check = 0; my $port = 7000; my $host = "divisionbyzero.net"; my @who, $line; socket(TALKER,PF_INET,SOCK_STREAM,getprotobyname('tcp')); connect(TALKER,sockaddr_in($port,inet_aton($host))); select(TALKER); $| = 1; select('stdout'); sleep 1; print TALKER "who\n"; while(<TALKER>) { if(m/\+-{1,80}\+/) { $check++; } if($check) { push @who, $_; } last if ($check > 2); } print TALKER "quit\n"; close TALKER; print "Content-type: text/html\n\n"; print << "end_header"; <html> <head> <title>Who's on Ancient Realms II</title> </head> <body bgcolor=black text=white link=green vlink=green alink=purple> <center> <h3>Users Currently logged on:</h3> end_header foreach $line (@who) { chomp $line; $line =~ s/\e\[0m*//g; $line =~ s/^\s+//; $line =~ s/\s+$//; $line =~ s/ /\&nbsp;/g; print "$line <br>\n"; } print "</center></body></html>"; exit 0;