title: How do I get an empty value to be an empty value instead of a hash?
body: <p>I'm having trouble acquiring the value of middle name from my XML file.  </p>
  
  <p>This is my XML file:</p>
  
  <pre><code>&lt;PERSON&gt;
  &lt;ID&gt;1&lt;/ID&gt;
  &lt;FIRSTNAME&gt;JOHN&lt;/FIRSTNAME&gt;
  &lt;MIDDLENAME&gt;&lt;/MIDDLENAME&gt;
  &lt;LASTNAME&gt;SMITH&lt;/LASTNAME&gt;
  &lt;/PERSON&gt;
  </code></pre>
  
  <p>This is how I access my XML file:</p>
  
  <pre><code>// [...]
  use XML::Simple;
  
  my $file = shift;
  
  open FILE,"$file" or die $!;
  my @rawFile = &lt;FILE&gt;;
  close (FILE);
  
  my $xml = new XML::Simple;
  
  my $data = $xml-&gt;XMLin("@rawFile");
  
  my $place = "PERSON"
  my $field = "MIDDLENAME"
  my $value = $data-&gt;{$place}-&gt;{$self-&gt;{field}};
  
  if (defined $value)
  {
       print "Value is $value"
       print Dumper($data-&gt;{$place}); 
  }
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>Value is [HASH(0x8ed6e28)]
  $VAR1 = {
      'ID' =&gt; '1',
      'FIRSTNAME' =&gt; 'JOHN',
      'MIDDLENAME' =&gt; {},
      'LASTNAME' =&gt; 'SMITH',
      'PHONE' =&gt; '5551234'
  }
  </code></pre>
  
  <p>How do I access my middle name $value so that it returns <code>""</code> (an empty string) instead of <code>[HASH(0x8ed6e28)]</code>?</p>
  
  <p>Note that if <code>$field="FIRSTNAME"</code> then the proper value of <code>"John"</code> is returned in <code>$value</code>.</p>