UPDATE: There are a number of golf tricks that I've left out. For instance ("out", "in")[$users{$n} = /\b$n\b/] manages to both remember and select the current state, removing one line. But readability suffers.#!/usr/bin/perl -l -w0777 @users{split /\s+/, <DATA>}=(); while(sleep 2) { $_ = `users`; for my $n (keys %users) { if ($users{$n} xor /\b$n\b/) { $users{$n} = /\b$n\b/; print localtime() . " $n has logged ", $users{$n} ? "in" : "out" +; } } }
In reply to Re^2: Shorten this code
by tilly
in thread Shorten this code
by hostyle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |