小编st.*_*st.的帖子

如何访问嵌套Perl哈希的值?

我是Perl的新手,我有一个非常简单的问题,但在查阅我的Perl书时我找不到答案.

打印结果时

Dumper($request);
Run Code Online (Sandbox Code Playgroud)

我得到以下结果:

$VAR1 = bless( {
             '_protocol' => 'HTTP/1.1',
             '_content' => '',
             '_uri' => bless( do{\(my $o = 'http://myawesomeserver.org:8081/counter/')}, 'URI::http' ),
             '_headers' => bless( {
                                    'user-agent' => 'Mozilla/5.0 (X11; U; Linux i686; en; rv:1.9.0.4) Gecko/20080528 Epiphany/2.22 Firefox/3.0',
                                    'connection' => 'keep-alive',
                                    'cache-control' => 'max-age=0',
                                    'keep-alive' => '300',
                                    'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
                                    'accept-language' => 'en-us,en;q=0.5',
                                    'accept-encoding' => 'gzip,deflate',
                                    'host' => 'localhost:8081',
                                    'accept-charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'
                                  }, 'HTTP::Headers' ),
             '_method' => 'GET',
             '_handle' => bless( \*Symbol::GEN0, 'FileHandle' )
           }, 'HTTP::Server::Simple::Dispatched::Request' );
Run Code Online (Sandbox Code Playgroud)

如何访问'_method'('GET')或'host'('localhost:8081')的值.

我知道这是一个简单的问题,但Perl在开始时有点神秘.

perl hash perl-data-structures

10
推荐指数
1
解决办法
3994
查看次数

标签 统计

hash ×1

perl ×1

perl-data-structures ×1