revert all changes since 0.5
[catagits/HTTP-Request-AsCGI.git] / examples / synopsis.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use CGI;
7 use HTTP::Request;
8 use HTTP::Request::AsCGI;
9
10 my $request = HTTP::Request->new( GET => 'http://www.host.com/' );
11 my $stdout;
12
13 {
14     my $c = HTTP::Request::AsCGI->new($request)->setup;
15     my $q = CGI->new;
16
17     print $q->header,
18           $q->start_html('Hello World'),
19           $q->h1('Hello World'),
20           $q->end_html;
21
22     $stdout = $c->stdout;
23
24     # enviroment and descriptors will automatically be restored when $c is destructed.
25 }
26
27 while ( my $line = $stdout->getline ) {
28     print $line;
29 }