in reply to diff output; unix commands
It may not be exactly what you want, in that it captures all of the output into an array.@lines = (`diff $args $file1 $file2`); for (@lines) { print; }
Or, if you really want the output from diff in a scalar as a single string, then you need to (temporarily) change the input record separator $/ to something other than newline, typically the null value will suffice. This snippet will accomplish the task:
bedk's solution is probably better because you can filter the output from diff one line at a time through a regex, and save/process only the lines you want.{ local $/ = '\0'; $line = `diff $args $file1 $file2`; print $line; }
|
|---|