title: How can I make a batch file to act like a simple grep using Perl?
body: <p>I already know the obvious answer to this question: "just download &lt;insert favorite windows grep or grep-like tool here&gt;".  However, I work in an environment with strict controls by the local IT staff as to what we're allowed to have on our computers.  Suffice it to say: I have access to Perl on Windows XP.  Here's a quick Perl script I came up with that does what I want, but I haven't figured up how to set up a batch file such that I can either pipe a command output into it, or pass a file (or list of files?) as an argument after the "expression to grep":</p>
  
  <pre>
  perl -n -e "print $_ if (m![expression]!);" [filename]
  </pre>
  
  <p>How do I write a batch script that I can do something like, for example:</p>
  
  <pre>
  dir | grep.bat mypattern
  grep.bat mypattern myfile.txt
  </pre>
  
  <p><strong>EDIT</strong>: Even though I marked another "answer", I wanted to give kudos to <a href="https://stackoverflow.com/questions/106053/how-to-make-a-batch-file-to-act-like-a-simple-grep-using-perl#106099">Ray Hayes answer</a>, as it is really the "Windows Way" to do it, even if another answer is technically closer to what I wanted.</p>