TWFjIGNvbXBsaWFudCBmb3Igc2VuZEdGV0xpc3Quc2gK

This commit is contained in:
911mxl
2010-04-18 16:54:59 +00:00
parent 6f3ddd0424
commit 8faa05263e
2 changed files with 18 additions and 14 deletions

View File

@@ -17,6 +17,9 @@
use strict;
use warnings;
use Digest::MD5 qw(md5_base64);
use File::stat;
use POSIX qw(locale_h);
use POSIX qw(strftime);
die "Usage: $^X $0 subscription.txt\n" unless @ARGV;
@@ -26,6 +29,11 @@ my $data = readFile($file);
# Remove already existing checksum
$data =~ s/^.*!\s*checksum[\s\-:]+([\w\+\/=]+).*\n//gmi;
# Update timestamp
setlocale(LC_TIME, "C");
my $timestamp = strftime("%a, %d %b %Y %H:%M:%S %z", localtime(stat($file)->mtime));
$data =~ s/^!\s*Last Modified:.*$/! Last Modified: $timestamp/mi;
# Calculate new checksum: remove all CR symbols and empty
# lines and get an MD5 checksum of the result (base64-encoded,
# without the trailing = characters).