#!/usr/bin/perl -w0777 @users{split /\s+/, <DATA>}=(); while(sleep 2) { for my $n (keys %users) { $_ = `users`; $state = ''; $users{$n} = 1, $state = 'in' if !$users{$n} && /\b$n\b/; $users{$n} = 0, $state = 'out' if $users{$n} && !/\b$n\b/; print localtime() . " $n has logged $state\n" if $state; } }
In reply to Re: Shorten this code
by ccn
in thread Shorten this code
by hostyle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |