Neil Wei
Neil Wei

Reputation: 15

what code should I use to open a link or file in CGI perl

I want to open a new link after my perl script by using cgi. Is there any function allows me to print html in my perl script?

like

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

Upvotes: 0

Views: 248

Answers (1)

J Singh
J Singh

Reputation: 162

There are many options out there, but You may use LWP::Simple. Below is an example usage from a tutorial here:

my $url = 'http://freshair.npr.org/dayFA.cfm?todayDate=current'; # Just an example: the URL for the most recent /Fresh Air/ show

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

Upvotes: 1

Related Questions