我正在使用下面的哈希数组,并且如果四个特定参数相同,我只想显示基于“日期时间”的最新哈希。让我使用下面的代码提供一个示例...
如果 'toy, kind, Stage, Step' 相同,那么我只想将该哈希存储到一个新的哈希数组中。
原始哈希数组
$VAR1 = [
{
'Color' => 'green',
'2nd Color' => 'blue',
'3rd Color' => 'yellow',
'toy' => 'truck',
'toy_type' => 'ford',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 01:49:19'
},
{
'Color' => 'red',
'2nd Color' => 'green',
'3rd Color' => 'yellow',
'toy' => 'truck',
'toy_type' => 'ford',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 01:46:17'
},
{
'Color' => 'red',
'2nd Color' => 'blue',
'3rd Color' => 'green',
'toy' => 'truck',
'toy_type' => 'chevy',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 01:52:14'
},
{
'Color' => 'red',
'2nd Color' => 'blue',
'3rd Color' => 'yellow',
'toy' => 'truck',
'toy_type' => 'chevy',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 01:24:14'
},
{
'Color' => 'white',
'2nd Color' => 'blue',
'3rd Color' => 'yellow',
'toy' => 'truck',
'toy_type' => 'gmc',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 06:24:14'
},
我想保存到变量的新哈希数组:
$VAR2 = [
{
'Color' => 'green',
'2nd Color' => 'blue',
'3rd Color' => 'yellow',
'toy' => 'truck',
'toy_type' => 'ford',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 01:49:19'
},
{
'Color' => 'red',
'2nd Color' => 'blue',
'3rd Color' => 'green',
'toy' => 'truck',
'toy_type' => 'chevy',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 01:52:14'
},
{
'Color' => 'white',
'2nd Color' => 'blue',
'3rd Color' => 'yellow',
'toy' => 'truck',
'toy_type' => 'gmc',
'kind' => '4door',
'Stage' => 'Production',
'Step' => 'Platform',
'Datetime' => '2012/06/08 06:24:14'
},
请注意,我只希望存储最新的福特和最近的雪佛兰,但因为只有一个 gmc,所以我也希望存储它。
我指的是 perldsc (http://perldoc.perl.org/perldsc.html) 文档,但它没有详细介绍。这甚至可能吗?