in reply to Re: formatting STDOUT
in thread formatting STDOUT

Im running a binary which returns text - without me being able to do any handling e.g. concatenating strings. I want to change the default formatting to include a timestamp.

Replies are listed 'Best First'.
Re^3: formatting STDOUT
by lupey (Monk) on May 31, 2005 at 13:02 UTC
    You can capture the output from an executable file by using backticks ``. Then, you can do whatever you want to the output: add a prefix, a suffix, or change it completely with regular expressions. In the following code, I'm capturing the output of echo and prefixing the date. Replace echo with the binary of your choice.
    use strict; my $system_call = `echo hello world`; my $output = scalar(localtime())." $system_call"; print STDOUT $output,"\n"; # output # Tue May 31 09:04:22 2005 hello world

    If this isn't what you are looking for, please be more explicit in your posts.

    lupey