title: Only print matching lines in perl from the command line
body: <p>I'm trying to extract all ip addresses from a file. So far, I'm just using</p>
  
  <pre><code>cat foo.txt | perl -pe 's/.*?((\d{1,3}\.){3}\d{1,3}).*/\1/'
  </code></pre>
  
  <p>but this also prints lines that don't contain a match. I can fix this by piping through grep, but this seems like it ought to be unnecessary, and could lead to errors if the regexes don't match up perfectly.</p>
  
  <p>Is there a simpler way to accomplish this?</p>