On Perlmonks you need to close your open code tags or else your post's formatting will be nigh unreadable. Also, your code doesn't make much sense:
#my $path = '/opt/finance/File1';
+
my $path = q|/tmp/File1|;
my $PMN = 'KKDDI';
my $MON = 'DDIID';
my $YEAR ='2013';
my $MON='JAN';
my $DATE='12';
my $CSV = $path . '.csv';
open CSV, ">$CSV" || die "Cannot open the file $CSV $! \n";
print CSV "\"ABCDE501,\"\"$PMN\"\",$MON/01/$YEAR,$MON/$DATE/$YEAR,$MON
+/$DATE/$Y\
EAR\"\n";
# Data hash contains values that has to be printed.
+
foreach my $key (keys %DataHash)
{
print CSV $DataHash{$key};
}
close(CSV);
Here you are writing the header to the CSV in a specific order but you are iterating willy-nilly over a hash which is not guaranteed to produce results in that same order.
perl -e 'my %hash = (q|first|=>1,q|third|=>3,q|second|=>2); print key
+s %hash;'
firstsecondthird
Celebrate Intellectual Diversity
|