Skip to content

Instantly share code, notes, and snippets.

@azumakuniyuki
Created November 25, 2011 16:32
Show Gist options
  • Save azumakuniyuki/1393918 to your computer and use it in GitHub Desktop.
Save azumakuniyuki/1393918 to your computer and use it in GitHub Desktop.
Generate queue identifier of Sendmail
#!/usr/local/bin/perl
use strict;
use warnings;
use Time::Piece;
my $current = new Time::Piece();
my $idchars = []; push( @$idchars , '0'..'9', 'A'..'Z', 'a'..'x' );
my $queueid = {
'Y' => $idchars->[ $current->_year() % 60 ],
'M' => $idchars->[ $current->_mon() ],
'D' => $idchars->[ $current->mday() ],
'h' => $idchars->[ $current->hour() ],
'm' => $idchars->[ $current->min() ],
's' => $idchars->[ $current->sec() ],
'q' => $idchars->[ int rand(60) ],
'p' => sprintf( "%05d", $$ ) };
print $queueid->{$_} for ( qw|Y M D h m s q p| );
print qq(\n);
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment