in reply to Generate unique ids of maximum length
I'll give you a concept instead of code:
For what I understand you need 5 steps
The magic is of course in step 4 (and you have to care about about different lengths of numbers in step 2)
for instance you could start to investigate the first n chars of each \w+ string in a loop.
As long as a grep(/$shortend\w*/) keys %strings counts more than 1 match you have to try again with a larger $n.
you can extend this method to grep(/$pre\w*$post/) ...
To further shorten the recomposed string you might consider using CamelCase instead of _ as delimiter (i.e. uppercase first character)
To be clear, all of this doesn't guaranty len(strings) <= $length, so you might be forced to skip readability for some keys in an extra step of shortening.
Cheers Rolf
|
|---|