title: perl regex replace only part of string
body: <p>I need to write a perl regex to convert  </p>
  
  <pre><code>site.company.com =&gt; dc=site,dc=company,dc=com
  </code></pre>
  
  <p>Unfortunately I am not able to remove the trailing "," using the regex I came with below. I could of course remove the trailing "," in the next statement but would prefer that to be handled as a part of the regex.</p>
  
  <pre><code>$data="site.company.com";
  $data =~ s/([^.]+)\.?/dc=$1,/g;
  print $data;
  </code></pre>
  
  <p>This above code prints:</p>
  
  <pre><code>dc=site,dc=company,dc=com,
  </code></pre>
  
  <p>Thanks in advance.</p>