通过http打开远程文件

d13*_*r43 2 perl screen-scraping module http

有没有像File :: Remote那样的perl模块,它可以通过http(只读)工作吗?就像是

$magic_module->open( SCRAPE, "http://somesite.com/");
while(<SCRAPE>)
{
  #do something     
}
Run Code Online (Sandbox Code Playgroud)

Igo*_*bin 5

当然是.你可以使用LWP::Simple:

use LWP::Simple;
my $content = get $url;
Run Code Online (Sandbox Code Playgroud)

不要忘记检查内容是否为空:

die "Can't download $url" unless defined $content;
Run Code Online (Sandbox Code Playgroud)

$contentundef在下载过程中发生一些错误.