3 use Cwd qw( realpath );
4 use File::Basename qw( fileparse );
6 @cfg = ('.wake', ( (fileparse( realpath($0) ))[1] ) . '.wake');
10 $macre = "$x$x:$x$x:$x$x:$x$x:$x$x:$x$x";
11 $ipre = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}";
13 foreach my $cfg (@cfg) {
20 my($host, $hw, $ip) = split;
21 push @{$mac->{lc($host)}}, { MAC => $hw, IP => $ip };
26 foreach $host (@ARGV) {
27 if ($host =~ /$macre/) {
28 print qx(wakeonlan $host);
30 elsif (@physical = @{$mac->{lc($host)}}) {
31 foreach my $mac (@physical) {
33 print qx(wakeonlan -i $mac->{IP} $mac->{MAC});
36 print qx(wakeonlan $mac->{MAC});
41 print lc($host) . ": no such host in the list.\n";
46 foreach $host (sort keys %$mac) {
47 $physical = $mac->{lc($host)};
48 foreach my $mac (@$physical) {
49 print "$host -> $mac->{MAC} -> $mac->{IP}\n";