Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: How to Prepending a timestamp to each line of output from a command

by haukex (Archbishop)
on Jun 07, 2017 at 13:50 UTC ( [id://1192274]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to Prepending a timestamp to each line of output from a command
in thread How to Prepending a timestamp to each line of output from a command

I'm sorry, but I don't fully understand what you're trying to do. It would be best if you could explain more, with a runnable SSCCE, example input and expected output. Otherwise I am left guessing, for example, based on your code it's not clear to me what @abc contains. Is this a list of commands you want to run, or is it the output of another command? If it's the latter, note that the other monks have already shown you how to handle that, like Discipulus's post here. How are you running the external command, from the command line with the input piped to the Perl script like in the gnomon example (which my code handles), or do you want to invoke the external command from inside the Perl script? If it's the latter, note that my code might not be the best way to do this, and you might need to switch to a module like IPC::Run.

Is this possible to make it a subroutine and call it by default in all STDOUT?

Are you asking how you can modify your own Perl script's output to prefix it with the current time (like a log), instead of another program's output?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1192274]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-20 13:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found