in reply to Verify string as ethernet address

I would probably change
$mac =~ s/-/:/g; #to $mac =~ s/[^0-9A-F]+/:/g;
weed out all the trash chars, I mean, why not?
                - Ant

Replies are listed 'Best First'.
Re: Re: Verify string as ethernet address
by fs (Monk) on May 30, 2001 at 21:52 UTC
    ":" and "-" are equivalent octet seperators. The presence of any other characters means the string isn't a valid ethernet address. With that change "dead beef is cool!" would match, but it shouldn't.
      Macintoshes tend to display their MAC address as a series of space separated octets. What you really want to do is to check that the octets are separated by a \W character. That way, you'll get "44:45 53,4f'2g;56" but not "dead beef is cool!". -- iain. <http://eh.org/~koschei/>
      oooh, you're assuming users are typing in separators they are supposed to, or failing... that works too... :)
                      - Ant