I'm creating an XLS/CSV file from an array of hashes.
The array of hashes (basicaly record set) has the table columns relative to the select statement.
So i'm assuming (correct me if i'm wrong), that the order of keys in the hash is the same order of the SQL select statement.
However when I use the following code..
The $head var has the order of the column headings different.
Is their some internal ordering going on here?
What's causing the difference in column(keys) order?
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
The array of hashes (basicaly record set) has the table columns relative to the select statement.
So i'm assuming (correct me if i'm wrong), that the order of keys in the hash is the same order of the SQL select statement.
However when I use the following code..
Code:
for(@logs){
$i++;
my $row;
# Build Header + Row info
while (my ($key, $value) = each(%$_)){
if($i == 1){
$head .= "\"$key\",";
}
if($key eq "Used"){
my @tm = split(/\./,$value);
$value = $tm[0];
}
$row .= "\"$value\",";
}
# drop extra commas + add newline char
$row = substr($row,0,length($row)-1);
$row .= "\n";
$xls .= $row;
}
The $head var has the order of the column headings different.
Is their some internal ordering going on here?
What's causing the difference in column(keys) order?
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!