#!/usr/bin/perl -w

use strict;

print <<EOF;
<?xml version="1.0" encoding="UTF-8"?> 
<kml xmlns="http://www.opengis.net/kml/2.2"> 
  <Document> 
    <Style id="redLine"> 
      <LineStyle> 
        <color>ff0000ff</color> 
        <width>3</width> 
      </LineStyle> 
    </Style> 
    <Placemark> 
      <styleUrl>#redLine</styleUrl> 
      <name></name> 
      <LineString> 
        <altitudeMode>clampToGround</altitudeMode> 
        <coordinates> 
EOF

while( <> )
{
    chomp;
    s/#.*$//;
    s/^\s+//;
    next if /^$/;
    my @values= split /\s+/;
    print join(",", @values[1,0,2]), "\n";
}

print <<EOF;
        </coordinates> 
      </LineString> 
    </Placemark> 
  </Document> 
</kml>
EOF


