newbie: unusual email output

D

Duke of Hazard

I have this code:
-----------------

print MAIL "Comments if any:\n";
print MAIL "================\n\n";
print MAIL "$x_comments";
print MAIL "\n\n";

close (MAIL);

Which produces this unexpected output when x_comments is null
-------------------------------------------------------------

Comments if any:
================



omments if any:
================


Any idea why it is printing it twice?

Thanks,

Faraz
 
J

Jürgen Exner

Duke said:
I have this code:
-----------------

print MAIL "Comments if any:\n";
print MAIL "================\n\n";
print MAIL "$x_comments";
print MAIL "\n\n";

close (MAIL);

Which produces this unexpected output when x_comments is null

What null? The text November-Uniform-Lima-Lima?
The number 0?
A binary value of \0x00?
-------------------------------------------------------------

Comments if any:
================



omments if any:
================


Any idea why it is printing it twice?

Well, the code you are showing to us won't print anything but an error
message about MAIL not being opened. What is your real code?

(Hint: your problem probably has nothing to do with those print statements
but with some 'interesting' logic in your program).

jue
 
D

Duke of Hazard

Here's the code pasted below. Everything works as it should, except
the last line seems to get printed twice.

###################################################
# mailing faraz_hussainyahoo.com cc'ing $x_email1 #
###################################################

$mail_prog = '/usr/sbin/sendmail -t' ;


if ($x_email1) {

open (MAIL, "|$mail_prog");
print MAIL "From: $r0\n";
print MAIL "To: $r0,$r1,$r2,$r3\n";
print MAIL "Cc: $x_email1\n";
print MAIL "Subject: ISRA - New member\n";
print MAIL "The following person has joined ISRA\n";
print MAIL "====================================\n\n";
print MAIL "$x_lastname, $x_firstname\n\n";

print MAIL "DOB, sex\n";
print MAIL "==========\n\n";
print MAIL "$x_dob, $x_sex\n\n";

print MAIL "Address 1\n";
print MAIL "==========\n\n";
print MAIL "$x_address1 \n $address2\n";

print MAIL "City, state and zip:\n";
print MAIL "====================\n\n";
print MAIL "$x_city ,$x_state ,$x_zip \n\n";

print MAIL "Home, work and cellphone\n";
print MAIL "========================\n\n";
print MAIL "$x_homephone , $x_workphone ,$x_cellphone \n\n";

print MAIL "With the following rating:\n";
print MAIL "==============================\n\n";
print MAIL "$x_rating\n\n";
print MAIL "The following contact information was provided:\n";
print MAIL "===============================================\n\n";
print MAIL "$x_email1, $x_email2\n\n";

print MAIL "Volunteer?\n";
print MAIL "==========\n\n";
print MAIL "$x_volunteer\n\n";

print MAIL "Comments if any:\n";
print MAIL "================\n\n";
print MAIL "$x_comments";
print MAIL "\n\n";

close (MAIL);
} # end of if statement

##################################################################
##################################################################
 
B

Brad Olin

On 22 Jan 2004 07:03:34 -0800, (e-mail address removed) (Duke of Hazard)
wrote:

Your script is similar to a script I have. I think you could use a some
error management, an easer style, and a tip on email headers.
Here's the code pasted below. Everything works as it should, except
the last line seems to get printed twice.

###################################################
# mailing faraz_hussainyahoo.com cc'ing $x_email1 #
###################################################

$mail_prog = '/usr/sbin/sendmail -t' ;


if ($x_email1) {

open (MAIL, "|$mail_prog");

If this open fails, which happens, then your script will fail and you
won't know it. Try this...

open MAIL, "|/usr/sbin/sendmail -t" or die "Can't open sendmail: $!\n";

You then go through each line with it's own print statement, nothing
wrong with this, but it is easer to follow/maintain/format if you...

print MAIL <<eof;
From: $r0
To: $r0,$r1,$r2,$r3
Cc: $x_email1
Subject: ISRA - New member

The following person has joined ISRA
====================================
<insert the rest of the body here>
eof
close MAIL or die "Can't close sendmail: $!/$?\n";
} # end of if
print MAIL "From: $r0\n";
print MAIL "To: $r0,$r1,$r2,$r3\n";
print MAIL "Cc: $x_email1\n";
print MAIL "Subject: ISRA - New member\n";
print MAIL "The following person has joined ISRA\n";


Here I want to point out that there MUST be a blank line between the
last header and the body of the email. This may seem like I'm picking a
nit, but it's not really me... every email related program requires it
as the separator between header and body. This may well be what is
causing the problem you are looking for.



Brad
 
N

nobull

Here's the code pasted below. Everything works as it should, except
the last line seems to get printed twice.

[snip incomplete code]

Well, the code you are showing to us won't do anything because it's
all wrapped in an if with a condition that'll be undefined.

What is your real code?

(Hint: your problem probably has nothing to do with those print
statements but with some 'interesting' logic in your program).

Deja vu?

(Further hint: Got any forks?)

Please see the posting guidelines that are posted frequently in
comp.lang.perl.misc for advice on how to ask questions effectively in
technical newsgroups.

This newsgroup does not exist (see FAQ). Please do not start threads
here.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top