my $fh_contents = <$fh>;
# rip out old serial
my ($old_serial) = $fh_contents =~ /IN\s+SOA\s+\S+\s+\S+\s*(?:\s*\;.+\n)*\((?:\s*\;.+\n)*\s*(\d+)/;
- my ($ymd,$iter) = $old_serial =~ /(\d{4}\d{2}\d{2})(\d{2})/;
+ my ($ymd,$iter) = $old_serial =~ /(\d{4}\d{2}\d{2})(\d{1,2})/;
my $new_serial = strftime("%Y%m%d",gmtime())."01";
if ($ymd eq strftime("%Y%m%d",gmtime())) {
- $new_serial = $ymd.($iter+1);
+ $new_serial = $ymd.sprintf('%02d',$iter+1);
}
$fh_contents =~ s/(IN\s+SOA\s+\S+\s+\S+\s*(?:\s*\;.+\n)*\((?:\s*\;.+\n)*\s*)(\d+)/${1}${new_serial}/;
print {$fh_new} $fh_contents;