|
下面是一个截取网页信息的perl代码:
- #!/usr/bin/perl
- use strict;
- use LWP::Simple;
- my $content = get("http://www.w3.weather.com/weather/print/POXX0016");
- $content =~ s/.*<!-- begin loop -->(.*)<!-- end loop -->.*/$1/s;
- my @day = split /<TR>/, $content;
- shift @day;
- my ($day, $date, $img, $temp, $precip);
- my $tomorrow;
- foreach $_ (@day) {
- ($day) = /(\w+)<\/A>/s;
- ($date) = /<BR> (.+?)</s;
- ($img) = /(\d+)\.gif/s;
- $img = $ARGV[0] . $img . '.png';
- ($temp) = /<B>(.*?)<\/B>/s;
- $temp =~ s/°/chr(186)/eg;
- $temp =~ s|(\d+)|sprintf "%d", ($1 - 32) * 5 / 9|eg;
- ($precip) = /(\d+ %)/;
- print $img . "\n" . $temp . "C\n" . $precip . "\n";
- }
复制代码
但在执行过程中出现如下错误:
- Can't locate LWP/Simple.pm in @INC (@INC contains: /etc/perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux /usr/lib64/perl5/vendor_perl/5.8.8 /usr/lib64/perl5/vendor_perl /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux /usr/lib64/perl5/site_perl/5.8.8 /usr/lib64/perl5/site_perl /usr/lib64/perl5/5.8.8/x86_64-linux /usr/lib64/perl5/5.8.8 /usr/local/lib/site_perl .) at ./weather_log.plx line 3.
- BEGIN failed--compilation aborted at ./weather_log.plx line 3.
复制代码
下面可以找到这个模块的位置:
- $ locate Simple.pm
- /usr/lib64/perl5/5.8.8/Test/Simple.pm
- /usr/lib64/perl5/5.8.8/Filter/Simple.pm
复制代码
如何才能让脚本运行?:ask |
|