Perl script to read property.xml and create install.properties file
how to read multiple lines and split keyName and keyValue
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, '<', "property.xml" or die "property.xml: $!";
open(CTS,">install.properties") or die $!;
while ( my $line = <$fh> ) {
if ($line =~ m/\<entry.*\<\/entry\>$/i ){ # how to read multiple line
my ($keyName, $keyValue) = split(//, $line); # how to split
print CTS $keyName = $keyValue;
}
}
property.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="TYPE">
Rel
</entry>
<!-- tst -->
<entry key="LOCATION">
C:/Rel-LOCATION
</entry>
<entry key="HOST">
localhost
</entry>
</properties>
install.properties
TYPE = Rel
LOCATION = C:/Rel-LOCATION
HOST = localhost