我有一串格式化的數據,我想推送到一個數組,但我的Perl技能缺乏。將格式化的數據推送到Perl中的數組中
的字符串是:
'ShoreTelCallStateInfo' => [
{
'callStateDetail' => 'Active',
'callState' => 'OnHold',
'callInfo' => {
'callerIDName' => 'Joel Lewis',
'callID' => '66766',
'lineID' => '3947',
'connectedIDName' => 'VM-Forward',
'calledID' => '2105',
'callerID' => '1955',
'isInbound' => 'false',
'calledIDName' => 'VM-Forward',
'callReason' => 'None',
'callUniqueID' => '2488927099',
'connectedID' => '2105',
'isExternal' => 'false',
'callGUID' => '{00030000-67CA-537E-3FD8-0010492377D9}'
}
},
{
'callStateDetail' => 'Active',
'callState' => 'Connected',
'callInfo' => {
'callerIDName' => 'Lewis Joel',
'callID' => '73202',
'lineID' => '3947',
'connectedIDName' => 'Lewis Joel',
'calledID' => '1955',
'callerID' => '+1385#######',
'isInbound' => 'true',
'calledIDName' => 'Joel Lewis',
'callReason' => 'None',
'callUniqueID' => '2193468845',
'connectedID' => '+1385#######',
'isExternal' => 'true',
'callGUID' => '{00030000-6809-537E-3FD8-0010492377D9}'
}
}
]
};
我試圖簡單地創建數組和字符串分配,但是這是行不通的:
my @magicarray = $string;
是否有一個快速的方法來初始化數組與格式化的數據?
這不是一個字符串。如果你在開頭添加一個'{',那將是一個匿名散列。也許你的意思是一個「標量」? – choroba 2015-03-31 15:43:43
它看起來不像我的字符串 – 2015-03-31 15:43:52
它存儲爲一個字符串,我希望它被轉換。 – 2015-03-31 15:45:15