title: WHY NOT use awk inside perl?
body: <p>Probably this question has been asked many times about being able to include the awk one liner inside your perl script. But these questions were too specific to the problem wherein:</p>
  
  <ol>
  <li>a different approach was provided as a suggestion OR</li>
  <li>the syntax within the existing code was rectified OR</li>
  <li>Majority of the times -> solutions were provided using perl because experts favored using either awk or perl because they both do the same job. Yes. Perhaps. But i think awk is designed for targetting specific problems which can be solved in awk better than perl.</li>
  </ol>
  
  <p><strong>Example:</strong> I have the output of <code>ls -lart</code> and the 9th column is filename. I can easily do that in awk as <code>ls -lart|awk '{print $9}'</code>. Same thing of course can be done using perl using <code>readdir()</code>. But extracting 8th column or 7th column is not that easy in perl? Things become worse if I have to extract data pipe it to awk pipe it to sed etc.</p>
  
  <p><strong>Another Example:</strong>
  I have a specific DIR which has many files in some format like:</p>
  
  <pre><code>ABC_9090_DEF_10-22-30_13-07-2014.temp
  </code></pre>
  
  <p>notice the date_time.temp stamp part. The format here is <strong>ABC_4digits_DEF_hours-minutes-seconds_day-month-year</strong></p>
  
  <p>And I want to see only the new files created just now (say before 5 minutes from now). Approach using awk/sed is(pseudocode,let me know if u need me to copy actual one liner) :</p>
  
  <ol>
  <li><code>ls -lart|awk '{print $9}'|</code></li>
  <li><code>egrep</code> to extract 10-22-30_13-07-2014</li>
  <li>use sed to replace _ with -|awk to rearrange the to have the number in the format  YEARMONTHDAYHOURSMINUTESSECONDS.</li>
  <li>use awk again to compare this number using if($1>$mynum) against the variable(which supposedly has a number in the same format representing TODAYS TIME - 5 minutes)</li>
  </ol>
  
  <p><strong>Problem:</strong>
  But for some reason(other complexities) i thought of writing it in perl and i found that the if condition <strong>if ($1>$mynum)</strong> throws error when i am using it in perl using system command. It says syntax error for using '>' even when using with single quotes,double quotes,no quotes.</p>
  
  <p>Can someone tell me in general:</p>
  
  <ol>
  <li>Why would someone NOT use awk,sed instead of perl in this scenario if given a choice?</li>
  <li>Generic explanation not specific to this problem on things one should remember while including awk or sed inside perl(which hopefully should solve this specific problem too.</li>
  </ol>