http://www.perlmonks.org?node_id=467287


in reply to How to increment a MAC Address?

I missed this thread earlier, and the approach I took is pretty similar to zengargoyle's.

#!/usr/bin/perl use strict; use warnings; #use constant MAX_VAL => 255; use constant MAX_VAL => 99; my @MAC=(0) x 6; sub PrintMAC { # print join(':',map {sprintf('%02X',$_)} @_),"\n"; print join(':',map {sprintf('%02D',$_)} @_),"\n"; } my $CurNO = 5; while ($CurNO >= 0) { while ($MAC[$CurNO] < MAX_VAL) { PrintMAC(@MAC); $MAC[$CurNO]++; } $CurNO--; } PrintMAC(@MAC);

On a side note... if you uncomment the two commented lines and comment out the lines immediately below them, you'll get addresses in the full range.