In this case, I'd argue for optimising
readability as you probably aren't updating your DNS maps thousands of times per second. Speed is not an issue here, so for readability I think
MeowChow's
version is the best if you really need to extract the components of the serial number. Despite the general under-use of
unpack, what the line intends is pretty clear I think, though one might want to glance at the docs before modifying it. The intent of
samtreagar's
method is even more obvious to the reader. Of course if you were processing millions of lines of data tagged with a similar serial number, then it may be worth the effort to look at speed, but then
samtreagar has still got the winner (though I'd be careful how many times I'd
++ the serial number - it's not a real number after all).
--
I'd like to be able to assign to an luser