title: Perl search for string and get the full line from text file
body: <p>I want to search for a string and get the full line from a text file through Perl scripting.</p>
  
  <p>So the text file will be like the following.</p>
  
  <pre><code>data-key-1,col-1.1,col-1.2
  data-key-2,col-2.1,col-2.2
  data-key-3,col-3.1,col-3.2
  </code></pre>
  
  <p>Here I want to apply <code>data-key-1</code> as the search string and get the full line into a Perl variable. </p>
  
  <p>Here I want the exact replacement of <code>grep "data-key-1" data.csv</code> in the shell.</p>
  
  <p>Some syntax like the following worked while running in the console.</p>
  
  <pre><code>perl -wln -e 'print if /\bAPPLE\b/' your_file
  </code></pre>
  
  <p>But how can I place it in a script? With the <code>perl</code> keyword we can't put it into a script. Is there a way to avoid the loops?</p>