in reply to formatting output from system call

G'day mark4444az,

Perhaps something like this:

`your_command | tee test.txt` =~ /your_capturing_regex/

Here's an example:

$ perl -le '`date | tee test.txt` =~ /^(\w+)/; print $1' Tue
$ cat test.txt Tue 18 Mar 2014 11:02:34 EST

Update:

Your post was a little unclear. If you wanted to capture part of the output and only store the captured part in the ouput file, you could do something like this:

system "echo @{[`your_command` =~ /your_capturing_regex/]} > test.txt"

Here's an example of doing it this way:

$ perl -e 'system "echo @{[`date` =~ /^(\w+)/]} > test.txt"'
$ cat test.txt Tue

-- Ken