in reply to Creating a CSV file

But the time value HH:MM:SS causes problems...

How? If this is a CSV file, you only need to worry about commas and quotation marks.
Update: I see--you're having issues parsing the date from your input lines. I was assuming the title of your post referred to this problem...

and I don't like assuming that the headers will match the values by printing the array of keys then the array of values.

One solution to this problem is to use a hash slice:

my @keys = ("Update Time", qw/Targets Complete Waiting/); my %hash; # fill in %hash (method not clear from OP) print join ',', @hash{ @keys }; # or use e.g. Text::CSV_XS