jnarayan81 has asked for the wisdom of the Perl Monks concerning the following question:
How to pre-pending a timestamp to each line of output from a command? Something like this https://i.stack.imgur.com/3EIM1.gif
I tried the following code, but fail to achieve it :(
use strict; use warnings; use POSIX q(strftime); my @abc = ("a", "b", "c", "d", "e"); my $time=POSIX::strftime('%a, %d %b %Y %T %z', localtime); foreach (@abc) { print "[$time]\t$_\n"; sleep 5;}
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to Prepending a timestamp to each line of output from a command
by choroba (Cardinal) on Jun 07, 2017 at 09:18 UTC | |
Re: How to Prepending a timestamp to each line of output from a command
by Discipulus (Canon) on Jun 07, 2017 at 09:20 UTC | |
Re: How to Prepending a timestamp to each line of output from a command
by haukex (Archbishop) on Jun 07, 2017 at 10:36 UTC | |
by jnarayan81 (Sexton) on Jun 07, 2017 at 13:08 UTC | |
by haukex (Archbishop) on Jun 07, 2017 at 13:50 UTC | |
Re: How to Prepending a timestamp to each line of output from a command
by thanos1983 (Parson) on Jun 07, 2017 at 12:07 UTC | |
Re: How to Prepending a timestamp to each line of output from a command
by dbander (Scribe) on Jun 07, 2017 at 11:37 UTC |
Back to
Seekers of Perl Wisdom