#!/usr/bin/perl -w

use strict;


foreach my $file (@ARGV) {

	open(XML,$file) || die "can't open '$file': $!";

	my $xml;
	while (<XML>) {
		$xml .= $_;
	}

	close(XML);

	if ($xml =~ s,<(\w+)\s+delimiter\s*=\s*"(\s[^"]+|[^"]+\s)"\s*>(.*?)</\1>,<$1>\n\t\t\t<delimiter>$2</delimiter>\n\t\t\t<value>$3</value>\n\t\t</$1>,gis) {
		open(XML,"> $file-new") || die "can't create '$file-new': $!";
		print XML $xml;
		close(XML);

		rename "$file-new","$file" || die "can't update original file '$file' with '$file-new': $!";

		print "$file converted\n";
	}
}

