[英]How to print complex data(Array of Hash) structure in perl
出於調試目的,我必須打印下面的哈希。 可以幫助我解決這個問題,因為我在復雜的數據結構方面不是新手:
use strict;
use warnings;
my $issueMap;
$issueMap = {
'project' => SOAP::Data->type(string => "abc"),
'type' => SOAP::Data->type(string => "3"),
'summary' => SOAP::Data->type(string => $title), #issueDesc
'description' => SOAP::Data->type(string => $issueDesc),
'components' => [{'id' => SOAP::Data->type(string => $component_id)}],
'customFieldValues' => SOAP::Data->type('Array' => [
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_10933'), values => [ SOAP::Data->type(string => $acbPath) ] },
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_10934'), values => [ SOAP::Data->type(string => $Path) ] },
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_10935'), values => [ SOAP::Data->type(string => $logPath) ] },
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_10071'), values => [ SOAP::Data->type(string => "PROD") ] },
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_10544'), values => [ SOAP::Data->type(string => $check_area) ] },
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_10842'), values => [ SOAP::Data->type(string => "Unavailable") ] },
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_14927'), values => [ SOAP::Data->type(string => "Unavailable") ] },
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_14930'), values => [ SOAP::Data->type(string => $mcn) ] }, #MCN
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_14929'), values => [ SOAP::Data->type(string => $serialno) ] }, #SERIAL
{ 'customfieldId' => SOAP::Data->type(string => 'customfield_10060'), values => [ SOAP::Data->type(string => "$user_runner") ] } #user
])
};
Debug
foreach my $check (%{$issueMap})
{
print $issueMap ->$check."\n";
}
Error : Can't call method "customFieldValues" on unblessed reference during printing hash.
我開始使用DDP
( Data::Printer
縮寫),它提供了更清晰,更好的彩色和靈活的輸出,而不是在屏幕上產生兩到三次的大量頁面線。
use DDP;
p $issueMap;
看看Data :: Printer的Customization for the many選項,比如expand
以深入了解你的結構。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.