倾倒风格
有时 Data::Dumper 还不够。有你要检查的驼鹿物体?大量相同的结构?想要的东西分类?有色? Data::Printer 是你的朋友。
use Data::Printer;
p $data_structure;
Data::Printer 写入 STDERR,如 warn
。这样可以更容易地找到输出。默认情况下,它会对哈希键进行排序并查看对象。
use Data::Printer;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
p $ua;
它将查看对象的所有方法,并列出内部。
LWP::UserAgent {
Parents LWP::MemberMixin
public methods (45) : add_handler, agent, clone, conn_cache, cookie_jar, credentials, default_header, default_headers, delete, env_proxy, from, get, get_basic_credentials, get_my_handler, handlers, head, is_online, is_protocol_supported, local_address, max_redirect, max_size, mirror, new, no_proxy, parse_head, post, prepare_request, progress, protocols_allowed, protocols_forbidden, proxy, put, redirect_ok, remove_handler, request, requests_redirectable, run_handlers, send_request, set_my_handler, show_progress, simple_request, ssl_opts, timeout, use_alarm, use_eval
private methods (4) : _agent, _need_proxy, _new_response, _process_colonic_headers
internals: {
def_headers HTTP::Headers,
handlers {
response_header HTTP::Config
},
local_address undef,
max_redirect 7,
max_size undef,
no_proxy [],
protocols_allowed undef,
protocols_forbidden undef,
proxy {},
requests_redirectable [
[0] "GET",
[1] "HEAD"
],
show_progress undef,
ssl_opts {
verify_hostname 1
},
timeout 180,
use_eval 1
}
}
你可以进一步配置它,因此它以某种方式序列化某些对象,或包含任意深度的对象。完整配置可在文档中找到 。