On Tue, 17 Sep 2002, Taco wrote:

>
>
> 4 hele regels code, ik schaam me.
>
> groetjes, Taco
>
> #!/usr/bin/perl -w
> local $/;
> open(IN,`kpsewhich context.tex`) || die "can't find context.tex";
> <IN> =~ /contextversion\{(\d+)\.(\d+)\.(\d+)\}/;
> print "version=" . sprintf("%4d%02d%02d",$1,$2,$3) . "\n";

That's better, thanks.
But it slurps the whole file, so I made it:

#!/usr/bin/perl -w
open(IN,`kpsewhich context.tex`) or die "can't find context.tex";
while(<IN>) {
    /contextversion\{(\d+)\.(\d+)\.(\d+)\}/ and
       printf("version=%4d%02d%02d\n",$1,$2,$3),last;
}

-- 
Wybo

Reply via email to