我在Perl中擁有以下數組中的數組,它們在數據庫中獲得多行。將陣列數組轉換爲散列陣列
$arrayref = [
[ 1, "name1", "name2" ],
[ 2, "name3", undef ],
[ 3, "name5", "name6" ],
[ 4, "name10", undef ],
];
我想使這個作爲哈希這樣
my @array = (
{ id => 1, name => "name1", l_name => "name2" },
{ id => 2, name => "name3", l_name => undef },
{ id => 3, name => "name5", l_name => "name6" },
{ id => 4, name => "name10", l_name => undef },
);
你從哪裏獲得您的數據與您的陣列?將它解析爲上游哈希(而不是稍後轉換)一個選項? – Sobrique