in reply to formatting STDOUT

open( CMD, "mycmd arguments wubba |" ) or die "Can't open pipe from my +cmd: $!\n"; while( <CMD> ) { print scalar localtime, ": ", $_; } close( CMD );

If you need fancier you might want to look at IPC::Run or the like.

--
We're looking for people in ATL

Replies are listed 'Best First'.
Re^2: formatting STDOUT
by Anonymous Monk on May 31, 2005 at 14:20 UTC

    I call an ARSPerl function e.g. login, which only returns a structure, but opens its own stream to STDOUT. I have redirected STDOUT to a log file which i also write to using print statements in the format e.g.

    Sun May 29 11:15:46 2005 Successfully generated query.

    but my redirect of STDOUT does not allow formatting. e.g. my line of perl code:

    ($control = ars_Login($arsserver, $arsuser, $arspass))
    produces this text, sent directly to STDOUT
    [ARS.xs 201] XS_ARS_ars_Login : ars_Login(arsprod, hp_servicecall, [nu +ll]) [ARS.xs 292] XS_ARS_ars_Login : finished.

    I want to enforce formatting rules so any print statement, even ones from the library call, have to obey i.e. including datetime.

    Janitored by holli - fixed formatting