[wplug] Interesting question du jour

billings at negate.org billings at negate.org
Mon Apr 21 16:36:30 EDT 2003


His solution is merely increasing the value of the last one, so if it's
a character, the next character, if it's a number, it increases the
number.  It doesn't "know" about hexidecimal math.

The solution I posted, albeit cryptic, does the hex addition, and
handles the 0 filling.  The only thing I didn't know what to do was in
cases of FF, but that shouldn't ever occur in a MAC address, unless you
are talking about a broadcast.

On Mon, 2003-04-21 at 16:19, Vanco, Donald wrote:
> Lance Tost wrote:
> > This should do it... again, invalid for MACs ending in FF.
> > 
> > #!/usr/bin/perl
> > 
> > open (IN, "/tmp/infile") or die "Cannot open file: $!\n";
> > open (OUT, ">/tmp/outfile") or die "Cannot open file: $!\n";
> > 
> > while (<IN>) {
> >         ($host, $mac) = split;
> >         (undef,undef,undef,undef,undef,$x) = split(':',$mac);
> >         printf OUT ("%s\t%s\n", $host, $mac);
> >         $y = sprintf ("%02X\n", (hex $x) + 1);
> >         $mac =~ s/:.{2}$/:$y/;
> >         printf OUT ("\t%s\n", $mac);
> > }
> > close (IN);
> > close (OUT);
> 
> Getting closer - but it still does goofy things:
> This is dorked:
> rcas0024        00:09:6B:49:08:2E
>         00:09:6B:49:08:3
> 
> Yet this is OK:
> rcas0026        00:09:6B:A3:03:ED
>         00:09:6B:A3:03:EE
> 
> here again:
> rcas0029        00:09:6B:63:0B:4B
>         00:09:6B:63:0B:5
> 
> 	...seems like the "number/letter" combo is not handled correctly
> 
> Don
> _______________________________________________
> wplug mailing list
> wplug at wplug.org
> http://www.wplug.org/mailman/listinfo/wplug
-- 
Jonathan S Billings <billings at negate.org>
TSFNKP



More information about the wplug mailing list