2
my %colorfigshash =();
my $tempcnt = <DATA>;
while($tempcnt=~m/Placement of Figure (?:[^\{]*)\{([^\{\}]*)\} Page ([^\n]*)\n/sg)
{
$colorfigshash{$1} = $2;
}
use Data::Dumper;
print Dumper \%colorfigshash;
__DATA__
Placement of Figure \hbox {10.7} Page 216
Pages in Color: 216
Placement of Figure \hbox {10.7} Page 217
Pages in Color: 217
$VAR1 = {
'10.7' => '216'
};
期望輸出
$VAR1 = {
'10.7' => '216-217'
};
我們怎麼能合併與以前的一個,如果該值密鑰是重複的。 如果Keys複製存儲在散列表中的最後一個值。任何人都可以提供解決方案,也將不勝感激。
是不是你的電流輸出'10.7' =>「217'? – xxfelixxx
'$ VAR1 = { '10.7'=>'216' };' – ssr1012
策略是將值推送到由'$ 1'索引的數組。然後,您可以處理數組中的值以生成更友好的字符串。您可以推送@ {$ colorfigshash {$ 1}},$ 2;' – xxfelixxx