Created
November 25, 2011 16:32
-
-
Save azumakuniyuki/1393918 to your computer and use it in GitHub Desktop.
Generate queue identifier of Sendmail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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