我应该使用什么代码来打开CGI perl中的链接或文件

时间:2016-04-21 02:46:41

标签: perl cgi

我想在perl脚本之后使用cgi打开一个新链接。是否有任何函数允许我在我的perl脚本中打印html?

喜欢

print header(-type => "text/html" );
print start_html("Register Form");
print end_html;

1 个答案:

答案 0 :(得分:1)

有很多选项,但您可以使用LWP::Simple。以下是a tutorial here的示例用法:

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;

  # Then go do things with $content, like this:

  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";
  }