~ubuntu-branches/ubuntu/utopic/libhttp-request-ascgi-perl/utopic

« back to all changes in this revision

Viewing changes to examples/synopsis.pl

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Krzyzaniak (eloy)
  • Date: 2005-11-16 13:59:02 UTC
  • Revision ID: james.westby@ubuntu.com-20051116135902-mczwe8n9t4ynigrj
Tags: upstream-0.2
ImportĀ upstreamĀ versionĀ 0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}