in reply to How to Prepending a timestamp to each line of output from a command
First of all you are assigning to $time once, so even if the format will work you'll end with the same time at each print: you must call it at each iteration directly or with a sub.
Second I do not find %a to be valid in the format description, see the following code:
use strict; use warnings; use POSIX q(strftime); my @abc = ("a", "b", "c", "d", "e"); foreach (@abc) { print '[',(strftime '%Y-%m-%d-%H-%M-%S', localtime()) +. "]\t$_\n"; sleep 1;} #output [2017-06-07-11-19-36] a [2017-06-07-11-19-37] b [2017-06-07-11-19-38] c [2017-06-07-11-19-39] d [2017-06-07-11-19-40] e
L*
|
|---|