我有一个问题希望你能帮忙?
这是我在理解哈希引用方面需要帮助的最后一部分
代码:
my $content_lengths; # this is at the top
foreach my $url ( # ... more stuff
# compare
if ( $mech->response->header('Content-Length') != $content_length ) {
print "$child_url: different content length: $content_length vs "
. $mech->response->header('Content-Length') . "!\n";
# store the urls that are found to have different content
# lengths to the base url only if the same url has not already been stored
$content_lengths->{$url}->{'different'}->{$child_url} = $mech->response->header('Content-Length');
} elsif ( $mech->response->header('Content-Length') == $content_length ) {
print "Content lengths are the same\n";
# store the urls that are found to have the same content length as the base
# url only if the same url has not already been stored
$content_lengths->{$url}->{'equal'}->{$child_url} = $mech->response->header('Content-Length');
}
使用 Data::Dumper 的样子
$VAR1 = {
'http://www.superuser.com/' => {
'difference' => {
'http://www.superuser.com/questions' => '10735',
'http://www.superuser.com/faq' => '13095'
},
'equal' => {
'http://www.superuser.com/ ' => '20892'
}
},
'http://www.stackoverflow.com/' => {
'difference' => {
'http://www.stackoverflow.com/faq' => '13015',
'http://www.stackoverflow.com/questions' => '10506'
},
'equal' => {
'http://www.stackoverflow.com/ ' => '33362'
}
}
};
我需要帮助:
我需要帮助了解访问散列引用中不同部分的各种方法,并使用它们来做事,例如打印它们。
因此,例如,我如何$url
从哈希引用中打印所有内容(即来自 Data::Dumper 的http://www.superuser.com/和http://www.stackoverflow.com/)
以及如何打印所有$child_url
或特定的一个/子集$child_url
等等?
非常感谢您对此的帮助,
多谢