|Do you know where your variables are?|
Generate unique ids of maximum lengthby lima1 (Curate)
|on Apr 12, 2010 at 16:11 UTC||Need Help??|
lima1 has asked for the
wisdom of the Perl Monks concerning the following question:
this is probably a trivial question but I could not find a good answer - most likely because I've searched with the wrong keywords.
My problem: I have a list of unique ids. I want to shorten the ids so that they have a maximum $length but the ids should still be unique. As another requirement, the new ids should be as similar as possible to the old ones.
The following quick and dirty solution works in my cases, but can fail (for example, set $length to 2 - I was just too lazy to fix this). It could be improved in several ways, for example instead of appending numbers from 1 to n, cat pre- and suffixes (in the DATA example, Lenoc3_caA, Lenoc3_caB instead of Lenoc3_ca1,...).
My question is now is there already something (better) on CPAN? If not, do you think it's worth packaging or do you have better solutions?