title: Using Perl to conditionally add tag to XML file
body: <p>I am not a developer in any way, but a network security guy. I need to insert a tag and value for an element if it does not already exist.</p>
  
  <p>Here's a snippet of my XML file</p>
  
  <pre><code>&lt;NessusClientData_V2&gt; 
      &lt;Policy&gt; 
      ... 
      &lt;Report&gt; 
      ... 
          &lt;ReportHost name="1.2.3.4"&gt; 
          ... 
              &lt;HostProperties&gt; 
              ... 
                  &lt;tag name="HOST_END"&gt;Thu Sep 17 17:23:19 2015&lt;/tag&gt; 
                  &lt;tag name="system-type"&gt;general-purpose&lt;/tag&gt; 
                  &lt;tag name="operating-system"&gt;MS WIN&lt;/tag&gt; 
                  &lt;tag name="ssh-auth-meth"&gt;password&lt;/tag&gt; 
                  &lt;tag name="ssh-login-used"&gt;backup&lt;/tag&gt; 
                  &lt;tag name="local-checks-proto"&gt;ssh&lt;/tag&gt; 
                  &lt;tag name="host-ip"&gt;1.2.3.4&lt;/tag&gt; 
                  &lt;tag name="HOST_START"&gt;Thu Sep 17 17:00:14 2015&lt;/tag&gt;
              &lt;/HostProperties&gt; 
              ...
  </code></pre>
  
  <p>I need to check each <code>ReportHost</code> element and create a </p>
  
  <pre><code>&lt;tag name="mac-address"&gt;
  </code></pre>
  
  <p>if it doesn't already have one.</p>
  
  <p>My output needs to contain all of the original information, but only needs to be added to.</p>