#!/usr/bin/perl -w use strict; $| = 1; my %users; $users{ $_ } = 0 for split "\n", do{ local $/; <DATA> }; { my %in; @in{ split / /, `users` } = (); for( keys %users ) { my $change = exists $in{$_} && !$users{$_} ? do{ $users{$_}++; 'in' } +: !exists $in{$_} && $users{$_} ? do{ $users{$_}--; 'out' } +: (); $change and print localtime() . " $_ has logged $change\n"; } sleep 2; redo; } __DATA__ Fred Wilma Barney Betty
In reply to Re: Shorten this code
by BrowserUk
in thread Shorten this code
by hostyle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |