傾倒風格
有時 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
}
}
你可以進一步配置它,因此它以某種方式序列化某些物件,或包含任意深度的物件。完整配置可在文件中找到 。