my %cache; sub is_valid_host { my $host = shift; return undef unless $host; $host = lc $host; unless (exists $cache{$host}) { my ($name,$aliases,$addrtype,$net) = gethostbyname($host); $cache{$host} = $name; } $cache{$host}; }