CfgTie
view release on metacpan or search on metacpan
lib/CfgTie/TieNamed.pm view on Meta::CPAN
{
# A routine to guess the human format of the serial number and come up with
# the next one. The minimal rule here is that the returned value will be
# no matter what, greater than the previous one.
# We are allowed 9 digits in base 10.
my $SN = shift;
my ($sec,$min,$hour,$MDay,$Month,$Year,$WDay,$YDay,$isDST)=localtime;
#Try YEAR-MONTH-DayOfMonth-Rev
# We have to make general calendar boundary conditions, plus be at an
# earlier date than now.
if ($SN =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d)$/ &&
$2 <= 12 && $3 <= $days_per_month[$2-1] &&
($1 < $Year ||
($1 == $Year && ($2 < $Month+1||($2==$Month+1&&$3<=$MDay+1)))))
{
# We passed the first part of the boundary conditions...
my $NewSn = $Year.($Month+1).($MDay+1)."0";
while ($NewSN <= $SN) {$NewSN++;}
return $NewSN;
( run in 3.079 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )