LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1217|回复: 2

perl新手,前辈们给指点一下...

[复制链接]
发表于 2007-6-12 20:40:23 | 显示全部楼层 |阅读模式
#!/usr/bin/perl

my $url = 'http://freshair.npr.org/dayFA.cfm?todayDate=current'

  use LWP::Simple;
  my $content = get $url;
  die "Couldn't get $url" unless defined $content;

  if($content =~ m/jazz/i) {
    print "They're talking about jazz today on Fresh Air!\n";
  } else {
    print "Fresh Air is apparently jazzless today.\n";
  }

为什么我运行后报错呢?

[root@ROOT perl]# perl getURL_test.pl
"use" not allowed in expression at getURL_test.pl line 4, at end of line
syntax error at getURL_test.pl line 4, near "use LWP::Simple"
Execution of getURL_test.pl aborted due to compilation errors.

英文又不好,请前辈们指点一下。谢了。。
发表于 2007-6-12 21:42:44 | 显示全部楼层
my $url那一行要加分号吧
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-6-12 22:45:35 | 显示全部楼层
谢谢大军。。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表