Anyway, here's a slightly modified version:
Note also that I took out the exit after the exec--you don't need that, because exec never returns.use LWP::Simple; my $user = shift or die "usage: $0 <username>"; $_ = get "http://www.efd.lth.se/loginload.shtml" or die "Cannot get!\n"; my $re = '<TR ALIGN=center>' . ('<TD>\s*([^<]+)</TD>' x 6) . '</TR +>'; my($load, $host); while (/$re/g) { $host = $1, $load = $5 if !defined $load || $5 < $load; } print "Host $host has load of $load\n"; exec("ssh $user\@$host.efd.lth.se") or die "Can't exec ssh: $!";
I think my regex might be a little more friendly, but I'm not absolutely sure. Note also that any regex solution will be less robust and less succeptible to HTML formatting changes than a solution like merlyn's.
Updated to test return value from exec, because I should've been more clear about exec and the possibility that it could return.
In reply to Re: Nothing special. Isn't that what Perls all about?
by btrott
in thread Nothing special. Isn't that what Perls all about?
by odie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |