#!/usr/bin/perl -w
  use strict;
  $|++;
  
  use CGI qw(-no_debug);
  
  while (<STDIN>) {
    last if /^\s*$/;
  }
 
 my $q = CGI->new(\*STDIN);
 
 ## process the data
 my $subscriber = join ":",
   map $q->param($_), 
   qw(name address1 address2 city state zip dayphone email);
 
 print STDERR "$subscriber\n";   # debugging
 
 ## send a confirmation
 my $email = $q->param('email');
 
 open SM, "|/usr/lib/sendmail -oi -t"
   or die "Cannot launch sendmail: $!";
 print SM <<END;
 To: $email
 From: merlyn\@stonehenge.con
 Subject: Thank you for your subscription!
 
 You will now receive Perl Hackers Weekly!
 
 END
 
 close SM;
 warn "sendmail exited with $?" if $?;
 exit 0;