File: synopsis.pl

package info (click to toggle)
libhttp-request-ascgi-perl 0.5-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 92 kB
  • ctags: 10
  • sloc: perl: 430; makefile: 46
file content (29 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/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;
}