NAME Regexp::Network - some useful routines for the DHCP bits and pieces. SYNOPSIS use Regexp::Network; print "$ip is valid!" if $ip =~ $ip_RE; my (@macs) = ($data =~ /\b($mac_RE)\b/g); @macs = map { cleanether($_) } @macs; DESCRIPTION Provide useful routines and constants and stuff for analysing assorted network log files and data. EXPORTATIONS As an Exporter, it provides (optionally): $ip_RE Matches an IP address. Mostly useful for extracting IPs from log files or validating them. e.g. print "IP is valid!" if ($ip =~ /$ip_RE/); It has weaknesses, but it will at least limit things to 0-255 rather than allowing 354.543.551.79485 as a valid IP. Has problems with things like 0123.01.5.6 (leading zeroes). $mac_RE Matches a MAC address. Either ':' or '-' separated. Either with leading zeroes, or without. Case insensitive. Once pulled, you can use cleanether on it to turn it into the canonical form. print "MAC is valid!" if ($mac =~ /$mac_RE/); cleanether() Cleans ethernet hardware addresses (MACs) into the preferred canonical form. This routine follows design by contract principles and dies if the MAC address is not parsable by $mac_RE, hence only pass suitable stuff in. $clean_MAC = cleanether($dirty_MAC); AUTHOR Iain Truskett Please report any bugs, or post any suggestions, to either the mailing list at (email to subscribe) or directly to the author at PLANS Impove ip_RE for leading noughts, and such like. COPYRIGHT Copyright (c) 2002 Iain Truskett. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. $Id: Network.pm,v 1.3 2002/04/05 07:56:05 koschei Exp $ ACKNOWLEDGEMENTS None really. Just happened to need the facilities of this module. SEE ALSO Memoize