How to parse a kml file without using Data::Dumper to print output(parsed data)
<p>I am fairly new to perl and i am using perl to parse a kml file. The code I am using works. However, i am currently using data::dumper to print the parsed to a file, which makes it troublesome since i have to read the file later. I was wondering if there was a better solution?
Here is my code:</p>

<pre><code>use strict;
use warnings;
use XML::Simple;
use Data::Dumper;

open (OUTPUT1,"&gt;output1.txt");
my $xml = new XML::Simple;
my $data = $xml-&gt;XMLin("test1.kml");

print OUTPUT1 Dumper($data-&gt;{Document}-&gt;{Folder}-&gt;{Folder});
</code></pre>

<p>here is the sample data:</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
&lt;kml xmlns="http://www.opengis.net/kml/2.2"&gt;
  &lt;Document&gt;
  &lt;name&gt;name&lt;/name&gt;
  &lt;open&gt;1&lt;/open&gt;
  &lt;Style id="redStar" xmlns=""&gt;
  &lt;IconStyle&gt;
    &lt;color&gt;FFFFFF00&lt;/color&gt;
    &lt;scale&gt;0.7&lt;/scale&gt;
    &lt;Icon&gt;
      &lt;href&gt;http://maps.google.com/mapfiles/kml/shapes/donut.png&lt;/href&gt;
    &lt;/Icon&gt;
  &lt;/IconStyle&gt;
  &lt;LabelStyle&gt;
    &lt;scale&gt;1.5&lt;/scale&gt;
  &lt;/LabelStyle&gt;
&lt;/Style&gt;
&lt;Style id="yellowCircle" xmlns=""&gt;\
    &lt;IconStyle&gt;&lt;color&gt;FF66FF00&lt;/color&gt;&lt;scale&gt;0.7&lt;/scale&gt;&lt;Icon&gt;     &lt;href&gt;http://maps.google.com/mapfiles/kml/shapes/square.png&lt;/href&gt;&lt;/Icon&gt;    &lt;/IconStyle&gt;&lt;LabelStyle&gt;&lt;scale&gt;0.8&lt;/scale&gt;&lt;/LabelStyle&gt;&lt;/Style&gt;
&lt;Style id="whiteCircle" xmlns=""&gt;
  &lt;IconStyle&gt;
    &lt;color&gt;FF0000AA&lt;/color&gt;
    &lt;scale&gt;0.7&lt;/scale&gt;
    &lt;Icon&gt;
      &lt;href&gt;http://maps.google.com/mapfiles/kml/paddle/wht-circle.png&lt;/href&gt;
    &lt;/Icon&gt;
  &lt;/IconStyle&gt;
  &lt;LabelStyle&gt;
    &lt;scale&gt;0.8&lt;/scale&gt;
  &lt;/LabelStyle&gt;
&lt;/Style&gt;
&lt;Style id="s_ylw-pushpin" xmlns=""&gt;
  &lt;IconStyle&gt;
    &lt;scale&gt;0.7&lt;/scale&gt;
    &lt;Icon&gt;
      &lt;href&gt;http://maps.google.com/mapfiles/kml/paddle/grn-diamond.png&lt;/href&gt;
    &lt;/Icon&gt;
    &lt;hotSpot x="32" y="1" xunits="pixels" yunits="pixels" /&gt;
  &lt;/IconStyle&gt;
  &lt;ListStyle&gt;
    &lt;ItemIcon&gt;
      &lt;href&gt;http://maps.google.com/mapfiles/kml/paddle/grn-diamond-lv.png&lt;/href&gt;
    &lt;/ItemIcon&gt;
  &lt;/ListStyle&gt;
&lt;/Style&gt;
&lt;Style id="s_ylw-pushpin_hl" xmlns=""&gt;
  &lt;IconStyle&gt;
    &lt;scale&gt;0.827273&lt;/scale&gt;
    &lt;Icon&gt;
      &lt;href&gt;http://maps.google.com/mapfiles/kml/paddle/grn-diamond.png&lt;/href&gt;
    &lt;/Icon&gt;
    &lt;hotSpot x="32" y="1" xunits="pixels" yunits="pixels" /&gt;
  &lt;/IconStyle&gt;
  &lt;ListStyle&gt;
    &lt;ItemIcon&gt;
      &lt;href&gt;http://maps.google.com/mapfiles/kml/paddle/grn-diamond-    lv.png&lt;/href&gt;
    &lt;/ItemIcon&gt;
  &lt;/ListStyle&gt;
&lt;/Style&gt;
&lt;Style id="blueCircle" xmlns=""&gt;
  &lt;IconStyle&gt;
    &lt;color&gt;FF0000FF&lt;/color&gt;
    &lt;scale&gt;1.0&lt;/scale&gt;
    &lt;Icon&gt;
                    &lt;href&gt;http://maps.google.com/mapfiles/kml/shapes/placemark_square.png&lt;/href&gt;
    &lt;/Icon&gt;
  &lt;/IconStyle&gt;
  &lt;LabelStyle&gt;
    &lt;scale&gt;0.8&lt;/scale&gt;
  &lt;/LabelStyle&gt;
&lt;/Style&gt;
&lt;Style id="greenCircle" xmlns=""&gt;
  &lt;IconStyle&gt;
    &lt;scale&gt;0.7&lt;/scale&gt;
    &lt;Icon&gt;
      &lt;href&gt;http://maps.google.com/mapfiles/kml/paddle/grn-circle.png&lt;/href&gt;
    &lt;/Icon&gt;
  &lt;/IconStyle&gt;
  &lt;LabelStyle&gt;
    &lt;scale&gt;0.8&lt;/scale&gt;
  &lt;/LabelStyle&gt;
&lt;/Style&gt;
&lt;Folder&gt;
&lt;name&gt;Circuits&lt;/name&gt;
  &lt;Folder&gt;
    &lt;name&gt;Circuit&lt;/name&gt;
    &lt;Folder&gt;
      &lt;name&gt;Segment&lt;/name&gt;
      &lt;Placemark&gt;
        &lt;name&gt;Segment1&lt;/name&gt;
        &lt;Style&gt;
          &lt;LineStyle id="#20605123_ARFHC.Style"&gt;
            &lt;color&gt;FF00FF00&lt;/color&gt;
            &lt;width&gt;2&lt;/width&gt;
          &lt;/LineStyle&gt;
        &lt;/Style&gt;
        &lt;LineString&gt;
          &lt;altitudeMode&gt;clampToGround&lt;/altitudeMode&gt;
          &lt;coordinates&gt;000.00000,0.000000
 &lt;/coordinates&gt;
        &lt;/LineString&gt;
      &lt;/Placemark&gt;
 &lt;Folder&gt;
      &lt;name&gt;Manhole&lt;/name&gt;
      &lt;Placemark&gt;
        &lt;name&gt;Manhole1&lt;/name&gt;
        &lt;styleUrl&gt;#blueCircle&lt;/styleUrl&gt;
        &lt;Point&gt;
          &lt;coordinates&gt;111.11111,111.111111
&lt;/coordinates&gt;
            &lt;/Point&gt;
          &lt;/Placemark&gt;
          &lt;Placemark&gt;
             &lt;name&gt;Manhole2&lt;/name&gt;
            &lt;styleUrl&gt;#blueCircle&lt;/styleUrl&gt;
            &lt;Point&gt;
              &lt;coordinates&gt;111.444444,3.2222222
&lt;/coordinates&gt;
            &lt;/Point&gt;
          &lt;/Placemark&gt;
  &lt;/Folder&gt;
      &lt;/Folder&gt;
    &lt;/Folder&gt;
  &lt;/Document&gt;
&lt;/kml&gt;
</code></pre>