use vars qw($idnum); sub unique { my $remote_addr = sprintf '%02X%02X%02X%02X', (split /\./, $ENV{'REMOTE_ADDR'}); unless(++$idnum < 0x10000) { sleep 1; $idnum = 0; } return sprintf '%012X.%s.%08X.%04X', time, $remote_addr, $$, $idnum; }