#!/usr/local/bin/perl # # Friends watch window WJ98 # open(UPLOAD, ">upload"); print UPLOAD ""; close(UPLOAD); sleep(1); while($line = ) { if ($line =~ /Friends online:/) { &read_friends; &print_friends; } elsif ($line =~ /Bark!! Bark!!! Your watchdog noticed something at \d+:\d\d/) { $line = ; chop($line); if ($line =~ /^Your friend (.+) has logged on./) { $friendlist{$1} = 1; &print_friends; } elsif ($line =~ /^Your friend (.+) has logged off./ || $line =~ /^Your friend (.+) went link dead and is disconnected./) { $friendlist{$1} = 0; &print_friends; } } } sub read_friends { local ($line, $friend); local (@arr); while($line = ) { if ($line =~ /^\S/) { last; } else { chop($line); $line =~ s/\s\s/\~/g; @arr = split(/\~/, $line); foreach $friend (@arr) { $friend =~ s/^\s//; if ($friend ne '') { $friendlist{$friend} = 1; } } } } } sub print_friends { local ($friend); print ""; foreach $friend (keys %friendlist) { if ($friendlist{$friend} == 1) { print "$friend\n"; } } } # EOB