我有以下代码:
Net::Pcap::loop($pcap, -1, \&proccess_packets, '');
sub proccess_packets {
my ($user_data, $header, $packet) = @_;
my $ip_packet = NetPacket::Ethernet::strip($packet);
my $tcp_packet = NetPacket::IP::strip($ip_packet);
my $tcp_obj = NetPacket::TCP->decode($tcp_packet);
if ($tcp_obj->{data}) {
my $request = HTTP::Request->parse($tcp_obj->{data});
my %headers = split /[:\n]/, $request->headers_as_string;
print Dumper($headers{'Accept-Language'}); # this line is printed
print $headers{'Accept-Language'}; # this line is not printed
}
}
有人可以解释为什么打印这一行:
print Dumper($headers{'Accept-Language'});
为什么不打印:
print $headers{'Accept-Language'};
这可能是什么问题?有人可以提出建议吗?它与libpcap的回调机制有关吗?