I’m trying to develop a script which will, in part, generate a list of MAC addresses from a given starting base. What I have as input is a list of MAC addresses, and need to increment by 1.
Examples:
00:1D:FE:12:37:1A (need to generate 00:1D:FE:12:37:1B)
00:1D:FE:12:37:49 (need to generate 00:1D:FE:12:37:4A)
00:1D:FE:12:37:4F (need to generate 00:1D:FE:12:37:50)
The restriction here is that I need to run this script on a machine that has no “extra” perl modules neither installed nor available, so the code would need to be included within the script. This means Net::MAC is out as a module, but I could potentially cannibalize some useful bits and include it but I’m thinking what I’m trying to do shouldn’t be entirely complex to implement in a small function utilizing pack(?) or something of the like.
I’ve found various threads around on forums like PerlMonks, but no one seems to have a conclusive answer. Any input would be appreciated!
It’s a 48-bit number. Parse it, increment it, format it.
Many Perl builds only support 32-bit numbers as integers, so I’ll avoid forming larger ints.