我正在尝试将哈希值分配给变量,但我无法将每个值分配给varIAble。请分享您的想法
say my %data = Dumper($data);
$VAR1 = {
'cnt' => 2000,
'inc' => 30,
'start' => 1440154820,
'end' => 1440154860,
'values' => [
'0.001234',
'0.001878',
'0.001849',
$start = 0.001234:1440154820
$end = 0.001849:1440154860
嗨,我正试图从上面的哈希
中将这些值分配给变量,如下所示$value1 = 0.001234:1440154820 # like $VAR1{values[0]:$VAR1{start}
$value2 = 0.001849:1440154860 # $VAR1{values[2]:$VAR1{end}
答案 0 :(得分:0)
这是你要求的吗?
use strict;
use warnings;
my $data = {
cnt => 2000,
inc => 30,
start => 1440154820,
end => 1440154860,
values => [0.001234, 0.001878, 0.001849],
};
my $start = join ':', $data->{values}[0], $data->{start};
my $end = join ':', $data->{values}[2], $data->{end};
print "\$start = $start\n";
print "\$end = $end\n";
$start = 0.001234:1440154820
$end = 0.001849:1440154860