in reply to can a script change itself?
Data::UUID will create a unique number, without having to know which id was last assigned. The number might be too big for you, though.
Update: This module is a standard implementation of jZed's suggestion.