Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3f93c489cce2183e78abc2990503f05b > files > 9

perl-HTTP-Request-AsCGI-0.9-2mdv2010.0.noarch.rpm

#!/usr/bin/perl

use strict;
use warnings;

use CGI;
use HTTP::Request;
use HTTP::Request::AsCGI;

my $request = HTTP::Request->new( GET => 'http://www.host.com/' );
my $stdout;

{
    my $c = HTTP::Request::AsCGI->new($request)->setup;
    my $q = CGI->new;

    print $q->header,
          $q->start_html('Hello World'),
          $q->h1('Hello World'),
          $q->end_html;

    $stdout = $c->stdout;

    # enviroment and descriptors will automatically be restored when $c is destructed.
}

while ( my $line = $stdout->getline ) {
    print $line;
}