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