Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 perl 来在线读取文本文件,使用如下调用:
$output = $ua->request($req)->as_string;
问题是输出中有很多我不想要的垃圾,例如
HTTP/1.1 200 OK Connection: close Date: etc...
有没有办法截断输出,所以我只得到文件的内容?
问题是您只是从中获取响应对象LWP::UserAgent并将其作为字符串转储。如果您只想获取内容:
LWP::UserAgent
# Get the response $response = $ua->request($req); # Get the content portion of the response $output = $response->content;
一切都是黑白的:https ://metacpan.org/pod/HTTP::Request