[18231] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 399 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 2 18:06:49 2001

Date: Fri, 2 Mar 2001 15:05:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983574319-v10-i399@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Mar 2001     Volume: 10 Number: 399

Today's topics:
        command line II <philly_fan1@hotmail.com>
    Re: command line <shanem@ll.mit.edu>
    Re: command line <philly_fan1@hotmail.com>
        Customized Error Messages <wells@cedarnet.org>
    Re: Customized Error Messages <godzilla@stomp.stomp.tokyo>
    Re: Customized Error Messages (Ben Okopnik)
    Re: Display Delay in Perl? <iltzu@sci.invalid>
    Re: flock and close   with  empty read strangeness <groovyt@erols.com>
    Re: flock and close   with  empty read strangeness (Gwyn Judd)
        GGI system() and backquotes question <mark_shutt@hotmail.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 2 Mar 2001 16:31:09 -0500
From: "PhillyFan" <philly_fan1@hotmail.com>
Subject: command line II
Message-Id: <97p21s$6u3$2@info.usuhs.mil>

Sorry about that long day.  I have a cgi which takes form inputs and than
after validated displays the form in html with the customers input.  The
second part of the request was to also have the form display the same way in
an email.  I have tried using:

sub mail
{


 $htmlfile ="$filenew";

  open (IN, "<$htmlfile") or die "Cannot open $htmlfile : $!\n";
    $sender = new Mail::Sender {smtp => 'mxg.usuhs.mil'};
    $sender->Open({ from => 'rmateen@usuhs.mil', to
=>'rafiqmateen@hotmail.com',
    subject =>  "$htmlfile",
    headers =>  "MIME-Version: 1.0\r\nContent-type:
text/html\r\nContent-Transfer-Encoding: 7bit"
    }) or die $Mail::Sender::Error,"\n";


 while (<IN>) { $sender->Send($_); };
  close IN;
  $sender->Close();

#unlink($htmlfile) || die "Can't delete  $htmlfile: $! ";

}

which by all account works as a separate program but inside the program I
have attached it opens the file but doesn't print it to the email.  The
email has a subject and all the rest but no body.  I checked the file I am
trying to bring in and it is correct permissions are 666 on the file.  Hence
I was wondering if there was another way around my dilemma hence the command
line inside my script.  Incidentally the command line argument works on my
webserver from any directory with no problem.  Long day it's a Friday some
insight would be helpful.  excuse the original post I know better just
tired.  Military duty awaits.  Have a nice weekend.


Here is the whole code:

#! /usr/bin/perl
$|=1;
use diagnostics;
use vars;
use CGI qw(:standard);
use Mail::Sender;

$count = 0;
@days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
@months = qw(January February March April May June July August September
October November December);
($mday, $mon, $year, $wday,) = (localtime)[3..6];
$yr=$year + 1900;

$filenew = "/tmp/html/fax2.html";


# The following accepts the data from the form

print"Content-type: text/html\n\n";

if ($ENV{'REQUEST_METHOD'} eq 'POST')
{

    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

    @pairs = split(/&/, $buffer);

    foreach $pair (@pairs)
    {
       ($name, $value) = split(/=/, $pair);
       $value =~ tr/+/ /;
       $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $FORM{$name} = $value;
    if(($count == 6) && ($name !~/Work_requested/) ) {&no_service}
    $count++;
    }
thankyou();
printout();

}

#The following creates the Thank You page display
sub thankyou
{
    htmlfiller();

}



# The following creates a page if no service department is selected

sub no_service
{

    print header;
    print start_html('Try again');
    print h1;
    print "<CENTER>You must select at least one";
    print p;
    print "SERVICE/WORK entry you are in need of";
    print p;
    print "Please use back button to correct";
    print h3;
    print "Thank you for your cooperation.";
    print "</CENTER>";
    print end_html();
    exit(0);
}

sub htmlfiller
{
    print header;
    print start_html('Thank you');
    print h3;
    print "<CENTER>Thank You $FORM{Requesting_official} for filling out a
request";
    print p;
    print "The following request will be sent to
$FORM{Approv_Official_email}";
    print p;
 print start_form();
 print "<TABLE cellSpacing=0 cellPadding=1 width=\"100%\" border=1>";
 print "<TBODY><TR><TD align=middle width=\"85%\" colSpan=3><STRONG>USUHS
SERVICE/WORK";
 print "REQUEST<BR>FACILITIES<BR>301-295-3045</STRONG></TD>";
 print "<TD align=middle width=\"15%\">";
 print "<b>$days[$wday],$months[$mon],$mday,$yr</b>";
 print "</TD></TR><TR><TD align=middle>To:Servicing Activity/Department
<b>FAC</b> </TD>";
 print "<TD align=middle>Date of Request <b>$FORM{DateRequested}<b/></TD>";
 print "<TD align=middle>Date Required <b>$FORM{DateRequired}</b></TD>";
 print "<TD align=middle>Email Address <b>$FORM{Email_address}</b>
</TD></TR></TBODY></TABLE>";
 print "<TABLE cellSpacing=0 cellPadding=2 width=\"100%\"
border=1><TBODY><TR>";
 print "<TD>From:Activity/Department <b>$FORM{Requesting_dept}</b></TD>";
   print "<TD>Room No. <b>$FORM{Room_number}</b></TD>";
 print "<TD>Telephone No.
<b>$FORM{Phone_number}</b></TD></TR></TBODY></TABLE>";
 print "<TABLE cellSpacing=0 cellPadding=0 width=100 border=0><TBODY>";
    print
"<TR><TD>\&nbsp;</TD></TR><TR><TD>\&nbsp;</TD></TR></TBODY></TABLE>";
 print "<CENTER><EM><STRONG>The Following Service/Work Is
Requested:</STRONG></EM><BR>";
 print "<TABLE cellSpacing=1 cellPadding=3 width=\"100%\" align=center
border=1>";
  print "<TBODY><TR>";
 if($FORM{Work_requested} eq "Keys")
 {print "<TD><INPUT type=radio value=Keys CHECKED>KEYS</TD>";}
 else{print "<TD><INPUT type=radio value=Keys>KEYS</TD>";}
 if($FORM{Work_requested} eq "Construction")
  {print "<TD><INPUT type=radio value=Construction
CHECKED>CONSTRUCTION</TD>";}
 else{print "<TD><INPUT type=radio value=Construction>CONSTRUCTION</TD>";}
    if($FORM{Work_requested} eq "Electrical")
 {print "<TD><INPUT type=radio value=Electrical CHECKED>ELECTRICAL</TD>";}
 else{print "<TD><INPUT type=radio value=Electrical>ELECTRICAL</TD>";}
 if($FORM{Work_requested} eq "Painting")
 {print "<TD><INPUT type=radio value=Painting CHECKED>PAINTING</TD></TR>";}
 else{print "<TD><INPUT type=radio value=Painting>PAINTING</TD></TR>";}
    if($FORM{Work_requested} eq "Other")
 {print "<TR><TD><INPUT type=radio value=Other CHECKED>OTHER</TD>";}
 else{print "<TR><TD><INPUT type=radio value=Other>OTHER</TD>";}
    print "<TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD></TR>";
 print
"<TR><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>&nbsp;</TD>";
 print "</TR></TBODY></TABLE></CENTER><BR>";
 print "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>";
 print "<TH align=left>Describe the Service/Work to be
performed:</TH></TR><TR>";
 print "<TD><b><TEXTAREA name=WorkDescription rows=4 cols=60>";
 print "$FORM{WorkDescription}</TEXTAREA></b></TD>";
 print "<TD>Once you fill out the form. The form will go to the approving";
    print " official's email box. The Approving Official will have to
forward the form";
    print " to<FONT color=blue> fac1\@mxg.usuhs.mil</FONT> with a statement
approving";
    print " your request. Facilities will send you email notification of
work request";
    print " approval.</TD></TR></TBODY></TABLE>";
 print "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>";
    print "<TH align=left>Justification:<TH></TR>";
 print "<TR><TD><b><TEXTAREA name=Justification rows=4
cols=60>$FORM{Justification}";
 print "</TEXTAREA></b></TD></TR></TBODY></TABLE>";
 print p;
 print p;
    print "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
 print "<TBODY><TR><TD>Type Name of Requesting Official
<strong>$FORM{Requesting_official} ";
    print "<TD>Type Email Address of Approving Official
<b>$FORM{Approv_Official_email}</b> ";
 print "</strong></TD></TD></TR></TBODY></TABLE>";
 print end_form();
 print "</CENTER>";
    print end_html();
}


sub printout
{
 open(OUT, ">$filenew") || die "Can't open $filenew: $!";
    while(<OUT>) {print;};
 print OUT "<CENTER>Thank You $FORM{Requesting_official} for filling out a
request\n";
 print OUT "<br>";
 print OUT "Approve request and forward to Facilities(fac1\@usuhs.mil)\n";
 print OUT "<br>";
 print OUT "<TABLE cellSpacing=0 cellPadding=1 width=\"100%\" border=1>\n";
 print OUT "<TBODY><TR><TD align=middle width=\"85%\"
colSpan=3><STRONG>USUHS SERVICE/WORK\n";
 print OUT "REQUEST<BR>FACILITIES<BR>301-295-3045</STRONG></TD>\n";
 print OUT "<TD align=middle width=\"15%\">\n";
 print OUT "<b>$days[$wday],$months[$mon],$mday,$yr</b>\n";
 print OUT "</TD></TR><TR><TD align=middle>To:Servicing Activity/Department
<b>FAC</b> </TD>\n";
 print OUT "<TD align=middle>Date of Request
<b>$FORM{DateRequested}<b/></TD>\n";
 print OUT "<TD align=middle>Date Required
<b>$FORM{DateRequired}</b></TD>\n";
 print OUT "<TD align=middle>Email Address <b>$FORM{Email_address}</b>\n";
 print OUT "</TD></TR></TBODY></TABLE>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=2 width=\"100%\"
border=1><TBODY><TR>\n";
 print OUT "<TD>From:Activity/Department
<b>$FORM{Requesting_dept}</b></TD>\n";
 print OUT "<TD>Room No. <b>$FORM{Room_number}</b></TD>\n";
 print OUT "<TD>Telephone No.
<b>$FORM{Phone_number}</b></TD></TR></TBODY></TABLE>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=100
border=0><TBODY>\n";
 print OUT
"<TR><TD>\&nbsp;</TD></TR><TR><TD>\&nbsp;</TD></TR></TBODY></TABLE>\n";
 print OUT "<CENTER><EM><STRONG>The Following Service/Work Is
Requested:</STRONG></EM><BR>\n";
 print OUT "<TABLE cellSpacing=1 cellPadding=3 width=\"100%\" align=center
border=1>\n";
 print OUT "<TBODY><TR>\n";
 if($FORM{Work_requested} eq "Keys")
 {print OUT "<TD><INPUT type=radio value=Keys CHECKED>KEYS</TD>\n";}
 else{print OUT "<TD><INPUT type=radio value=Keys>KEYS</TD>\n";}
 if($FORM{Work_requested} eq "Construction")
 {print OUT "<TD><INPUT type=radio value=Construction
CHECKED>CONSTRUCTION</TD>\n";}
 else{print OUT "<TD><INPUT type=radio
value=Construction>CONSTRUCTION</TD>\n";}
 if($FORM{Work_requested} eq "Electrical")
 {print OUT "<TD><INPUT type=radio value=Electrical
CHECKED>ELECTRICAL</TD>\n";}
 else{print OUT "<TD><INPUT type=radio value=Electrical>ELECTRICAL</TD>\n";}
 if($FORM{Work_requested} eq "Painting")
 {print OUT "<TD><INPUT type=radio value=Painting
CHECKED>PAINTING</TD></TR>\n";}
 else{print OUT "<TD><INPUT type=radio
value=Painting>PAINTING</TD></TR>\n";}
 if($FORM{Work_requested} eq "Other")
 {print OUT "<TR><TD><INPUT type=radio value=Other CHECKED>OTHER</TD>\n";}
 else{print OUT "<TR><TD><INPUT type=radio value=Other>OTHER</TD>\n";}
 print OUT "<TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD></TR>\n";
 print OUT
"<TR><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>&nbsp;</TD>\n";
 print OUT "</TR></TBODY></TABLE></CENTER><BR>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>\n";
 print OUT "<TH align=left>Describe the Service/Work to be
performed:</TH></TR><TR>\n";
 print OUT "<TD><b><TEXTAREA name=WorkDescription rows=4 cols=60>\n";
 print OUT "$FORM{WorkDescription}</TEXTAREA></b></TD>\n";
 print OUT "<TD>Once you fill out the form. The form will go to the
approving\n";
 print OUT " official's email box. The Approving Official will have to
forward the form\n";
 print OUT " to<FONT color=blue> fac1\@mxg.usuhs.mil</FONT> with a statement
approving\n";
 print OUT " your request. Facilities will send you email notification of
work request\n";
 print OUT " approval.</TD></TR></TBODY></TABLE>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>\n";
 print OUT "<TH align=left>Justification:<TH></TR>\n";
 print OUT "<TR><TD><b><TEXTAREA name=Justification rows=4
cols=60>$FORM{Justification}\n";
 print OUT "</TEXTAREA></b></TD></TR></TBODY></TABLE>\n";
 print OUT "p\n";
 print OUT "p\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>\n";
 print OUT "<TBODY><TR><TD>Type Name of Requesting Official
<strong>$FORM{Requesting_official}\n";
 print OUT "<TD>Type Email Address of Approving Official
<b>$FORM{Approv_Official_email}</b> \n";
 print OUT "</strong></TD></TD></TR></TBODY></TABLE>\n";
 print OUT "</CENTER>\n";

 #mail();

 system {'/tmp/html/Html.pl'} "$filenew";
}


# The following subroutine sends the mail in HTML format
sub mail
{


 $htmlfile ="$filenew";

  open (IN, "<$htmlfile") or die "Cannot open $htmlfile : $!\n";
    $sender = new Mail::Sender {smtp => 'mxg.usuhs.mil'};
    $sender->Open({ from => 'rmateen@usuhs.mil', to
=>'rafiqmateen@hotmail.com',
    subject =>  "$htmlfile",
    headers =>  "MIME-Version: 1.0\r\nContent-type:
text/html\r\nContent-Transfer-Encoding: 7bit"
    }) or die $Mail::Sender::Error,"\n";


 while (<IN>) { $sender->Send($_); };
  close IN;
  $sender->Close();

#unlink($htmlfile) || die "Can't delete  $htmlfile: $! ";

}
----- Original Message -----
From: "Shane McDaniel" <shanem@ll.mit.edu>
Newsgroups: comp.lang.perl.misc
Sent: Friday, March 02, 2001 2:35 PM
Subject: Re: command line


> Could you try to be a little clearer, your question doesn't make much
> sense.
>
> Rafiq Mateen wrote:
> >
> > I want to use the following command line argument       perl
/tmp/html/pl
> > /tmp/html.fax2.html
> > inside of another program but I am stuck.  Please help.




------------------------------

Date: Fri, 02 Mar 2001 14:35:33 -0500
From: Shane McDaniel <shanem@ll.mit.edu>
Subject: Re: command line
Message-Id: <3A9FF605.61A0AFBC@ll.mit.edu>

Could you try to be a little clearer, your question doesn't make much
sense.

Rafiq Mateen wrote:
> 
> I want to use the following command line argument       perl /tmp/html/pl
> /tmp/html.fax2.html
> inside of another program but I am stuck.  Please help.


------------------------------

Date: Fri, 2 Mar 2001 16:30:39 -0500
From: "PhillyFan" <philly_fan1@hotmail.com>
Subject: Re: command line
Message-Id: <97p20v$6u2$2@info.usuhs.mil>

Sorry about that long day.  I have a cgi which takes form inputs and than
after validated displays the form in html with the customers input.  The
second part of the request was to also have the form display the same way in
an email.  I have tried using:

sub mail
{


 $htmlfile ="$filenew";

  open (IN, "<$htmlfile") or die "Cannot open $htmlfile : $!\n";
    $sender = new Mail::Sender {smtp => 'mxg.usuhs.mil'};
    $sender->Open({ from => 'rmateen@usuhs.mil', to
=>'rafiqmateen@hotmail.com',
    subject =>  "$htmlfile",
    headers =>  "MIME-Version: 1.0\r\nContent-type:
text/html\r\nContent-Transfer-Encoding: 7bit"
    }) or die $Mail::Sender::Error,"\n";


 while (<IN>) { $sender->Send($_); };
  close IN;
  $sender->Close();

#unlink($htmlfile) || die "Can't delete  $htmlfile: $! ";

}

which by all account works as a separate program but inside the program I
have attached it opens the file but doesn't print it to the email.  The
email has a subject and all the rest but no body.  I checked the file I am
trying to bring in and it is correct permissions are 666 on the file.  Hence
I was wondering if there was another way around my dilemma hence the command
line inside my script.  Incidentally the command line argument works on my
webserver from any directory with no problem.  Long day it's a Friday some
insight would be helpful.  excuse the original post I know better just
tired.  Military duty awaits.  Have a nice weekend.


Here is the whole code:

#! /usr/bin/perl
$|=1;
use diagnostics;
use vars;
use CGI qw(:standard);
use Mail::Sender;

$count = 0;
@days = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
@months = qw(January February March April May June July August September
October November December);
($mday, $mon, $year, $wday,) = (localtime)[3..6];
$yr=$year + 1900;

$filenew = "/tmp/html/fax2.html";


# The following accepts the data from the form

print"Content-type: text/html\n\n";

if ($ENV{'REQUEST_METHOD'} eq 'POST')
{

    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

    @pairs = split(/&/, $buffer);

    foreach $pair (@pairs)
    {
       ($name, $value) = split(/=/, $pair);
       $value =~ tr/+/ /;
       $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

    $FORM{$name} = $value;
    if(($count == 6) && ($name !~/Work_requested/) ) {&no_service}
    $count++;
    }
thankyou();
printout();

}

#The following creates the Thank You page display
sub thankyou
{
    htmlfiller();

}



# The following creates a page if no service department is selected

sub no_service
{

    print header;
    print start_html('Try again');
    print h1;
    print "<CENTER>You must select at least one";
    print p;
    print "SERVICE/WORK entry you are in need of";
    print p;
    print "Please use back button to correct";
    print h3;
    print "Thank you for your cooperation.";
    print "</CENTER>";
    print end_html();
    exit(0);
}

sub htmlfiller
{
    print header;
    print start_html('Thank you');
    print h3;
    print "<CENTER>Thank You $FORM{Requesting_official} for filling out a
request";
    print p;
    print "The following request will be sent to
$FORM{Approv_Official_email}";
    print p;
 print start_form();
 print "<TABLE cellSpacing=0 cellPadding=1 width=\"100%\" border=1>";
 print "<TBODY><TR><TD align=middle width=\"85%\" colSpan=3><STRONG>USUHS
SERVICE/WORK";
 print "REQUEST<BR>FACILITIES<BR>301-295-3045</STRONG></TD>";
 print "<TD align=middle width=\"15%\">";
 print "<b>$days[$wday],$months[$mon],$mday,$yr</b>";
 print "</TD></TR><TR><TD align=middle>To:Servicing Activity/Department
<b>FAC</b> </TD>";
 print "<TD align=middle>Date of Request <b>$FORM{DateRequested}<b/></TD>";
 print "<TD align=middle>Date Required <b>$FORM{DateRequired}</b></TD>";
 print "<TD align=middle>Email Address <b>$FORM{Email_address}</b>
</TD></TR></TBODY></TABLE>";
 print "<TABLE cellSpacing=0 cellPadding=2 width=\"100%\"
border=1><TBODY><TR>";
 print "<TD>From:Activity/Department <b>$FORM{Requesting_dept}</b></TD>";
   print "<TD>Room No. <b>$FORM{Room_number}</b></TD>";
 print "<TD>Telephone No.
<b>$FORM{Phone_number}</b></TD></TR></TBODY></TABLE>";
 print "<TABLE cellSpacing=0 cellPadding=0 width=100 border=0><TBODY>";
    print
"<TR><TD>\&nbsp;</TD></TR><TR><TD>\&nbsp;</TD></TR></TBODY></TABLE>";
 print "<CENTER><EM><STRONG>The Following Service/Work Is
Requested:</STRONG></EM><BR>";
 print "<TABLE cellSpacing=1 cellPadding=3 width=\"100%\" align=center
border=1>";
  print "<TBODY><TR>";
 if($FORM{Work_requested} eq "Keys")
 {print "<TD><INPUT type=radio value=Keys CHECKED>KEYS</TD>";}
 else{print "<TD><INPUT type=radio value=Keys>KEYS</TD>";}
 if($FORM{Work_requested} eq "Construction")
  {print "<TD><INPUT type=radio value=Construction
CHECKED>CONSTRUCTION</TD>";}
 else{print "<TD><INPUT type=radio value=Construction>CONSTRUCTION</TD>";}
    if($FORM{Work_requested} eq "Electrical")
 {print "<TD><INPUT type=radio value=Electrical CHECKED>ELECTRICAL</TD>";}
 else{print "<TD><INPUT type=radio value=Electrical>ELECTRICAL</TD>";}
 if($FORM{Work_requested} eq "Painting")
 {print "<TD><INPUT type=radio value=Painting CHECKED>PAINTING</TD></TR>";}
 else{print "<TD><INPUT type=radio value=Painting>PAINTING</TD></TR>";}
    if($FORM{Work_requested} eq "Other")
 {print "<TR><TD><INPUT type=radio value=Other CHECKED>OTHER</TD>";}
 else{print "<TR><TD><INPUT type=radio value=Other>OTHER</TD>";}
    print "<TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD></TR>";
 print
"<TR><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>&nbsp;</TD>";
 print "</TR></TBODY></TABLE></CENTER><BR>";
 print "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>";
 print "<TH align=left>Describe the Service/Work to be
performed:</TH></TR><TR>";
 print "<TD><b><TEXTAREA name=WorkDescription rows=4 cols=60>";
 print "$FORM{WorkDescription}</TEXTAREA></b></TD>";
 print "<TD>Once you fill out the form. The form will go to the approving";
    print " official's email box. The Approving Official will have to
forward the form";
    print " to<FONT color=blue> fac1\@mxg.usuhs.mil</FONT> with a statement
approving";
    print " your request. Facilities will send you email notification of
work request";
    print " approval.</TD></TR></TBODY></TABLE>";
 print "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>";
    print "<TH align=left>Justification:<TH></TR>";
 print "<TR><TD><b><TEXTAREA name=Justification rows=4
cols=60>$FORM{Justification}";
 print "</TEXTAREA></b></TD></TR></TBODY></TABLE>";
 print p;
 print p;
    print "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>";
 print "<TBODY><TR><TD>Type Name of Requesting Official
<strong>$FORM{Requesting_official} ";
    print "<TD>Type Email Address of Approving Official
<b>$FORM{Approv_Official_email}</b> ";
 print "</strong></TD></TD></TR></TBODY></TABLE>";
 print end_form();
 print "</CENTER>";
    print end_html();
}


sub printout
{
 open(OUT, ">$filenew") || die "Can't open $filenew: $!";
    while(<OUT>) {print;};
 print OUT "<CENTER>Thank You $FORM{Requesting_official} for filling out a
request\n";
 print OUT "<br>";
 print OUT "Approve request and forward to Facilities(fac1\@usuhs.mil)\n";
 print OUT "<br>";
 print OUT "<TABLE cellSpacing=0 cellPadding=1 width=\"100%\" border=1>\n";
 print OUT "<TBODY><TR><TD align=middle width=\"85%\"
colSpan=3><STRONG>USUHS SERVICE/WORK\n";
 print OUT "REQUEST<BR>FACILITIES<BR>301-295-3045</STRONG></TD>\n";
 print OUT "<TD align=middle width=\"15%\">\n";
 print OUT "<b>$days[$wday],$months[$mon],$mday,$yr</b>\n";
 print OUT "</TD></TR><TR><TD align=middle>To:Servicing Activity/Department
<b>FAC</b> </TD>\n";
 print OUT "<TD align=middle>Date of Request
<b>$FORM{DateRequested}<b/></TD>\n";
 print OUT "<TD align=middle>Date Required
<b>$FORM{DateRequired}</b></TD>\n";
 print OUT "<TD align=middle>Email Address <b>$FORM{Email_address}</b>\n";
 print OUT "</TD></TR></TBODY></TABLE>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=2 width=\"100%\"
border=1><TBODY><TR>\n";
 print OUT "<TD>From:Activity/Department
<b>$FORM{Requesting_dept}</b></TD>\n";
 print OUT "<TD>Room No. <b>$FORM{Room_number}</b></TD>\n";
 print OUT "<TD>Telephone No.
<b>$FORM{Phone_number}</b></TD></TR></TBODY></TABLE>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=100
border=0><TBODY>\n";
 print OUT
"<TR><TD>\&nbsp;</TD></TR><TR><TD>\&nbsp;</TD></TR></TBODY></TABLE>\n";
 print OUT "<CENTER><EM><STRONG>The Following Service/Work Is
Requested:</STRONG></EM><BR>\n";
 print OUT "<TABLE cellSpacing=1 cellPadding=3 width=\"100%\" align=center
border=1>\n";
 print OUT "<TBODY><TR>\n";
 if($FORM{Work_requested} eq "Keys")
 {print OUT "<TD><INPUT type=radio value=Keys CHECKED>KEYS</TD>\n";}
 else{print OUT "<TD><INPUT type=radio value=Keys>KEYS</TD>\n";}
 if($FORM{Work_requested} eq "Construction")
 {print OUT "<TD><INPUT type=radio value=Construction
CHECKED>CONSTRUCTION</TD>\n";}
 else{print OUT "<TD><INPUT type=radio
value=Construction>CONSTRUCTION</TD>\n";}
 if($FORM{Work_requested} eq "Electrical")
 {print OUT "<TD><INPUT type=radio value=Electrical
CHECKED>ELECTRICAL</TD>\n";}
 else{print OUT "<TD><INPUT type=radio value=Electrical>ELECTRICAL</TD>\n";}
 if($FORM{Work_requested} eq "Painting")
 {print OUT "<TD><INPUT type=radio value=Painting
CHECKED>PAINTING</TD></TR>\n";}
 else{print OUT "<TD><INPUT type=radio
value=Painting>PAINTING</TD></TR>\n";}
 if($FORM{Work_requested} eq "Other")
 {print OUT "<TR><TD><INPUT type=radio value=Other CHECKED>OTHER</TD>\n";}
 else{print OUT "<TR><TD><INPUT type=radio value=Other>OTHER</TD>\n";}
 print OUT "<TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD></TR>\n";
 print OUT
"<TR><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>\&nbsp;</TD><TD>&nbsp;</TD>\n";
 print OUT "</TR></TBODY></TABLE></CENTER><BR>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>\n";
 print OUT "<TH align=left>Describe the Service/Work to be
performed:</TH></TR><TR>\n";
 print OUT "<TD><b><TEXTAREA name=WorkDescription rows=4 cols=60>\n";
 print OUT "$FORM{WorkDescription}</TEXTAREA></b></TD>\n";
 print OUT "<TD>Once you fill out the form. The form will go to the
approving\n";
 print OUT " official's email box. The Approving Official will have to
forward the form\n";
 print OUT " to<FONT color=blue> fac1\@mxg.usuhs.mil</FONT> with a statement
approving\n";
 print OUT " your request. Facilities will send you email notification of
work request\n";
 print OUT " approval.</TD></TR></TBODY></TABLE>\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\"
border=0><TBODY><TR>\n";
 print OUT "<TH align=left>Justification:<TH></TR>\n";
 print OUT "<TR><TD><b><TEXTAREA name=Justification rows=4
cols=60>$FORM{Justification}\n";
 print OUT "</TEXTAREA></b></TD></TR></TBODY></TABLE>\n";
 print OUT "p\n";
 print OUT "p\n";
 print OUT "<TABLE cellSpacing=0 cellPadding=0 width=\"100%\" border=0>\n";
 print OUT "<TBODY><TR><TD>Type Name of Requesting Official
<strong>$FORM{Requesting_official}\n";
 print OUT "<TD>Type Email Address of Approving Official
<b>$FORM{Approv_Official_email}</b> \n";
 print OUT "</strong></TD></TD></TR></TBODY></TABLE>\n";
 print OUT "</CENTER>\n";

 #mail();

 system {'/tmp/html/Html.pl'} "$filenew";
}


# The following subroutine sends the mail in HTML format
sub mail
{


 $htmlfile ="$filenew";

  open (IN, "<$htmlfile") or die "Cannot open $htmlfile : $!\n";
    $sender = new Mail::Sender {smtp => 'mxg.usuhs.mil'};
    $sender->Open({ from => 'rmateen@usuhs.mil', to
=>'rafiqmateen@hotmail.com',
    subject =>  "$htmlfile",
    headers =>  "MIME-Version: 1.0\r\nContent-type:
text/html\r\nContent-Transfer-Encoding: 7bit"
    }) or die $Mail::Sender::Error,"\n";


 while (<IN>) { $sender->Send($_); };
  close IN;
  $sender->Close();

#unlink($htmlfile) || die "Can't delete  $htmlfile: $! ";

}
----- Original Message -----
From: "Shane McDaniel" <shanem@ll.mit.edu>
Newsgroups: comp.lang.perl.misc
Sent: Friday, March 02, 2001 2:35 PM
Subject: Re: command line


> Could you try to be a little clearer, your question doesn't make much
> sense.
>
> Rafiq Mateen wrote:
> >
> > I want to use the following command line argument       perl
/tmp/html/pl
> > /tmp/html.fax2.html
> > inside of another program but I am stuck.  Please help.
"Shane McDaniel" <shanem@ll.mit.edu> wrote in message
news:3A9FF605.61A0AFBC@ll.mit.edu...
> Could you try to be a little clearer, your question doesn't make much
> sense.
>
> Rafiq Mateen wrote:
> >
> > I want to use the following command line argument       perl
/tmp/html/pl
> > /tmp/html.fax2.html
> > inside of another program but I am stuck.  Please help.




------------------------------

Date: Fri, 02 Mar 2001 12:48:03 -0600
From: Steve Wells <wells@cedarnet.org>
Subject: Customized Error Messages
Message-Id: <3A9FEAE3.EACAE57F@cedarnet.org>

Disclaimer:
I must apologize as I've had no formal training
in programming courses and I'm sure this is 
something you would learn in such a course.
A course like this might also teach me the 
proper phrases to use when trying to discuss 
such a topic so please bear with me.

First, I was looking through some code last
month and found the following technique when
information is being passed back from a 
subroutine.

($ret, $values) = subroutine({ attributes });

If the return value is undefined then an error
was generated and the value of the error is placed
in $values otherwise the return value is '1' and 
$value contained those items that had been 
processed.

I started using this and have been very happy 
with the results, however I would like to have the
ability to customize the error messages that are
returned for to the end user and enter the details
that a programmer would need in a flat file for review.

I'm envisioning something where the error messages
are returned as codes and the codes are then linked 
to the actual message in a configuration file.  The 
messages attached to these codes can then be
modified as needed by changing the config file.

What's the "right" way to do something like this and
what are some of the advantages/disadvantages?

Can you direct me to actual code as samples and other
required reading?

TIA,
STEVE


------------------------------

Date: Fri, 02 Mar 2001 13:21:24 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Customized Error Messages
Message-Id: <3AA00ED4.FCA5CAFB@stomp.stomp.tokyo>

Steve Wells wrote:
 
> Disclaimer:
> I must apologize as I've had no formal training
> in programming courses and I'm sure this is
> something you would learn in such a course.
> A course like this might also teach me the
> proper phrases to use when trying to discuss
> such a topic so please bear with me.

Never admit your weaknesses upfront. This is
diplomatic surrender. Many are offended by
this behavior, others will take advantage.
When you are unsure, keep your mouth shut
until you have done your homework and are
very sure, via background knowledge. If
not, cross your fingers and tell very
convincing lies.

(snippage)

> First, I was looking through some code last
> month and found the following technique when
> information is being passed back from a
> subroutine.
 
> ($ret, $values) = subroutine({ attributes });
 
> If the return value is undefined then an error
> was generated and the value of the error is placed
> in $values otherwise the return value is '1' and
> $value contained those items that had been processed.

    ^^  $values not $value

This is incorrect. Making a presumption yours is an
example ignoring syntax errors, this format you
present will return nothing for $values. Your $ret
will receive what is returned, only.

My test script below my signature displays problems
with this syntax you present. You would be prudent
to research and learn about subroutines and syntax
for subroutine calls, before attempting to incorporate
an error message system.

You will note both your assumptions and your syntax
is faulty in my TEST ONE; $values attains no value,
only $ret. 

In TEST TWO, my subroutine2 attempts to set values
for both $ret and $values, and fails. 

TEST THREE displays correct syntax for what you want
to do, per your example syntax.

When you are finished playing with this, remove
all three instances of:

($ret, $values, $return) = "";

You will note $ret carries over a value previously
set. This is an even greater error in programming;
this is false value which "appears" to have been
returned by subroutine1 when $attributes is "false."

For subroutine2, intially $ret displays this false
value, then loses its value when $attributes is set
to false. Both cases are erroneous.

You will also note my TEST THREE does not succumb
to this failure via false values. It returns correct
values regardless of previous events, having cleared
previous errors via correct value assignments.

Do yourself a favor by learning basics first, then
work towards more advanced techniques. With your
current knowledged displayed, you have no chance
of getting this right nor understanding how this
error messaging system is programmed. Research
and learn, then you will do well.


Godzilla!
--

TEST SCRIPT:
____________

#!perl

print "Content-type: text/plain\n\n";


## TEST ONE

print "TEST ONE:\n\n";

$attributes = "true";

($ret, $values) = subroutine1($attributes);

print "\$ret is: $ret\n\$values is: $values\n\n";

($ret, $values, $return) = "";

$attributes = "false";

($ret, $values) = subroutine1($attributes);

print "\$ret is: $ret\n\$values is: $values\n\n";


sub subroutine1
 {
  if ($attributes eq "true")
   { $return = "true"; }

  return $return;
 }


## TEST TWO

print "\n\nTEST TWO:\n\n";

$attributes = "true";

($ret, $values) = subroutine2($attributes);

print "\$ret is: $ret\n\$values is: $values\n\n";

($ret, $values, $return) = "";

$attributes = "false";

($ret, $values) = subroutine2($attributes);

print "\$ret is: $ret\n\$values is: $values\n\n";


sub subroutine2
 {
  if ($attributes eq "true")
   { 
    $ret = "true";
    $values = "true";
   }
 }


## TEST THREE

print "\n\nTEST THREE:\n\n";

$attributes = "true";

($ret, $values) = split (/:/, subroutine3($attributes));

print "\$ret is: $ret\n\$values is: $values\n\n";

($ret, $values, $return) = "";

$attributes = "false";

($ret, $values) = split (/:/, subroutine3($attributes));

print "\$ret is: $ret\n\$values is: $values\n\n";


sub subroutine3
 {
  if ($attributes eq "true")
   { 
    $return = "true:true";
    return $return;
   }
 }


exit;


PRINTED RESULTS:
________________


TEST ONE:

$ret is: true
$values is: 

$ret is: 
$values is: 



TEST TWO:

$ret is: true
$values is: 

$ret is: 
$values is: 



TEST THREE:

$ret is: true
$values is: true

$ret is: 
$values is:


------------------------------

Date: 2 Mar 2001 22:08:32 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Customized Error Messages
Message-Id: <slrn9a06i0.u1j.ben-fuzzybear@Odin.Thor>

The ancient archives of Fri, 02 Mar 2001 12:48:03 -0600 showed
Steve Wells of comp.lang.perl.misc speaking thus:

[ ... ]

>I'm envisioning something where the error messages
>are returned as codes and the codes are then linked 
>to the actual message in a configuration file.  The 
>messages attached to these codes can then be
>modified as needed by changing the config file.
>
>What's the "right" way to do something like this and
>what are some of the advantages/disadvantages?
>
>Can you direct me to actual code as samples and other
>required reading?


Take a look at 'exceptions.pl' (on my Debian Linux system, it's in 
/usr/lib/perl5/5.005; use your favorite file search utility to locate 
yours.) Tom Christiansen details usage and gives an example right at the 
top of the file. You can have it throw error codes, or detailed error 
messages - whatever you'd prefer.

There are lots of hits on "Exception" at CPAN, but I'll confess to still 
being quite clumsy around it. There may well be a module that does the 
same thing.


Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Democracy is two wolves and a sheep voting on what to have
for dinner. Liberty is two wolves attempting to have a sheep
for dinner and finding a well-informed, well-armed sheep.


------------------------------

Date: 2 Mar 2001 19:17:12 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Display Delay in Perl?
Message-Id: <983560379.15658@itz.pp.sci.fi>

In article <97lb5c$7st$2@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel wrote:
>According to Abigail <abigail@foad.org>:
>> 
>> perl -we '$| = 1; map {sleep print} "Hello" =~ /./g'
>
>Gee, you can give this special twist to just any program.  What if
>you want a two-second delay?  Oh, I know, override print().

  perl -we '$| = 2; map {sleep $|<< print} "Hello" =~ /./g'

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"/* If you don't understand, don't touch */"  -- Abigail in the monastery



------------------------------

Date: Fri, 02 Mar 2001 17:38:53 -0500
From: ZepHead <groovyt@erols.com>
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <groovyt-E8B0D7.17385302032001@virt-reader.news.rcn.net>

thanks everyone for your input and it all got me thinking
what the problem might be so i went and re read the perl 
docs (like for the 10th time in the last week) and WHAM 
it hit me .

A quick recap.  I check all functions for error returns
and never get any yet say 1 in 1000 reads i get an empty read
even though the next read the data IS THERE.
I lock everything etc...  so WTF?

Well it turns out that FLOCK is not all that is is cracked up to be
Why?  because it locks AFTER THE OPEN  to write  

take a look at this



if(open(FILEHANDLE,">$dirpath"))
{
   if(flock(FILEHANDLE,2))
   {

   }
}



it turns out the the open for write truncates/empties the file.

IMMEDIATELY!

now while we are waiting for the lock another process
comes in  and READS the truncated/emptied  file  ARRRGHHHH

So i have to say WHY isn't locking built into OPEN
and why doesn't the open get that lock BEFORE it is allowed
truncate?   anyway the fix was to use

sysopen(FILEHANDLE, $dirpath, O_WRONLY | O_CREAT)

which does not truncate/empty the file like an open.
thanks everyone it was your posts that got me thinking
and why i found the answer


thanks

Russ


------------------------------

Date: Fri, 02 Mar 2001 22:59:45 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <slrn9a09ev.8ve.tjla@thislove.dyndns.org>

I was shocked! How could ZepHead <groovyt@erols.com>
say such a terrible thing:

>if(open(FILEHANDLE,">$dirpath"))
>{
>   if(flock(FILEHANDLE,2))
>   {
>
>   }
>}
>
>it turns out the the open for write truncates/empties the file.

So open for update instead. That's mode '+<' for the hard of RTFM'ing.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Exploring the universe through meditation is like
studying human relationships through masturbation.
  Atheism/Freethought fortune cookie file


------------------------------

Date: Fri, 02 Mar 2001 21:30:04 -0000
From: Mark <mark_shutt@hotmail.com>
Subject: GGI system() and backquotes question
Message-Id: <ta046sm9bs9ad7@corp.supernews.com>

Hello,

I'm running MS Personal Web Server on Win98. I have been able to get some 
CGI scripts working, but I cannot use DOS commands such as `DIR` or system
(dir).  For example, as a test, a issue the following instruction:
  print `dir`;

When I execute this through the a browser located on the webserver (I am 
still running this through the server) I noticed a DOS box quickly comes 
up and goes. The page is never displayed and I have to go through Task 
Manger to end the task.

Is this some how a ScriptAlias issue? I have my .pl file mapped and perl 
scripts execute fine. I have since added .com (thinking the command.com 
may need to be seen here..I used "<path>\command.com %s") but that still 
doesn't seem to work.

Also, a second question. I get the following error when I try to include 
Win32::NetResource
------------
[Fri Mar  2 14:31:45 2001] C:\Inetpub\wwwroot\cgi-bin\release\release.pl: 
Can't load 'C:/Perl/site/lib/auto/Win32/NetResource/NetResource.dll' for 
module Win32::NetResource: load_file:A device attached to the system is 
not functioning at C:/Perl/lib/DynaLoader.pm line 200.
[Fri Mar  2 14:31:45 2001] C:\Inetpub\wwwroot\cgi-bin\release\release.pl:  
at C:\Inetpub\wwwroot\cgi-bin\release\release.pl line 21
[Fri Mar  2 14:31:45 2001] C:\Inetpub\wwwroot\cgi-bin\release\release.pl: 
Compilation failed in require at C:\Inetpub\wwwroot\cgi-
bin\release\release.pl line 21.
[Fri Mar  2 14:31:45 2001] C:\Inetpub\wwwroot\cgi-bin\release\release.pl: 
BEGIN failed--compilation aborted at C:\Inetpub\wwwroot\cgi-
bin\release\release.pl line 21.
------------

I would appreciate help on any of these issues.

Thanks.

Mark
 

--
Posted via CNET Help.com
http://www.help.com/


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 399
**************************************


home help back first fref pref prev next nref lref last post