#!/usr/bin/perl -CDS
use utf8;
+use POSIX qw(strftime);
# char-level modes
my $poetry = 0;
my $verbatim = 0;
my $metadata = shift @ARGV;
open F,"<",$metadata;
while (<F>) {
+ # Replace empty date with current date
+ if (/<date\s+\/>/ || /<date>\s*<\/date>/) {
+ $_ = "<date value=\">".strftime("%Y-%m-%d",localtime())."\">".
+ strftime("%d/%m/%Y",localtime())."</date>\n";
+ }
+ # Add current to date as fractional part to version
+ if (/<version>(\d*)(.\d*)?<\/version>/) {
+ my $ver = $1+time()/1E10;
+ $_=tag(sprintf("%g",$ver),"version")."\n";
+ }
print $_;
}
close F;
<document-info>
<author><first-name>Виктор</first-name><last-name>Вагнер</last-name></author>
<program-used>Perl</program-used>
-<date value="2013-11-12">12.11.2013</date>
+<date />
<src-url>http://www.wagner.pp.ru/~vitus/fiction</src-url>
-<id>00000</id>
-<version>0.8</version>
+<id>5056261e-13f6-4386-83be-2a363304fab3</id>
+<version>0.0</version>
</document-info>
</description>