title: Regex substitution using perl in application
body: <p>I've to do a regex substitution and I'm using perl for that; which looks similar to this</p>
  <blockquote>
  <p>$ABC=~s/APP_*.*?_LOG_(.*?)_.*/$1/</p>
  <p>print &quot;ABC=$ABC\n&quot;;</p>
  </blockquote>
  <p>Where <code>$ABC</code> can be of below format before and after substitution:</p>
  <pre><code>APP_184_PRD_LOG_O2_2M -&gt; O2
  APP_184_PRD_CFC_O2_6D -&gt; O2
  APP_046_STG_CFC_BCK_4W_1 -&gt; BCK
  APP_050_STG_LOG_OSS_8M_2 -&gt; OSS
  APP_050_STG_LOG_SAM_SOX_2M -&gt; SAM_SOX
  APP_050_STG_CFC_SAM_FOR_6M_3 -&gt; SAM_FOR
  
  Rules:-
  1st variable is always APP
  4th variable can be LOG or CFC
  We are concerned with variable no.5 or 6(in some cases)
  If the 6th variable has Number+(W/D/M), then 6th &amp; 7th variable to be removed
  </code></pre>
  <p>The substitution has to be a single liner (application restriction).</p>