Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New line & print problem 2

Status
Not open for further replies.

WayneC

IS-IT--Management
Jun 22, 2001
6
GB
With response and thanks for the reply to my earlier post
I have included the script that I am struggling with.


# Use the cgi unit
use cgi;

# Get the values from the form
$form = new CGI;

$subject="Mortgage Lead";
$tome="info\@flexiblehomeloans.co.uk";
$fromme="ADP Server";
$server="smtp.flexiblehomeloans.co.uk";

$server="smtp.flexiblehomeloans.co.uk";
$lastname=$form->param('lastname');
$firstname=$form->param('firstname');
$dateofbirth=$form->param('dateofbirth');
$address1=$form->param('address1');
$address2=$form->param('address2');
$city=$form->param('city');
$county=$form->param('county');
$postcode=$form->param('postcode');
$firsttime=$form->param('firsttime');
$homemover=$form->param('homemover');
$remortgage=$form->param('remortgage');
$review=$form->param('review');
$std=$form->param('std');
$number=$form->param('number');
$email=$form->param('email');

$lt='<';
$gt='>';

# Output the correct header
print &quot;Content-type: text/html\n\n&quot;;

# Save the message into a text file
open (messtxt,&quot;>message.txt&quot;);
print &quot;messtxt: $lastname\n&quot;;
print &quot;messtxt: $firstname\n&quot;;
print &quot;messtxt: $dateofbirth\n&quot;;
print &quot;messtxt: $address1\n&quot;;
print &quot;messtxt: $address2\n&quot;;
print &quot;messtxt: $city\n&quot;;
print &quot;messtxt: $county\n&quot;;
print &quot;messtxt: $postcode\n&quot;;
print &quot;messtxt: $firsttime\n&quot;;
print &quot;messtxt: $homemover\n&quot;;
print &quot;messtxt: $remortgage\n&quot;;
print &quot;messtxt $review\n&quot;;
print &quot;messtxt: $std)\n&quot;;
print &quot;messtxt: $number\n&quot;;
print &quot;messtxt: $email\n&quot;;
close messtxt;

# Build the Blat command line and execute it

$blat=&quot;blat.exe message.txt -s \&quot;$subject\&quot; -t \&quot;$tome\&quot; -f \&quot;$fromme\&quot; -server $server\&quot; &quot;;

system($blat);

print $blat;
print &quot;<br><br>Done.<br><br>&quot;;
print &quot;Mail sent to $raddr.&quot;;
 
It appears that you are trying to use a file handle incorrectly.

In order to print to a file, you must first open the file and get a [red]HANDLE[/red] on it. Like this,
open ([red]MESSTXT[/red],&quot;>message.txt&quot;) or die &quot;Failed to open output file, $!\n&quot;;

The [red]red[/red] part is the HANDLE.

Then, when you want to print to the file, you do it through the handle.

like,
print [red]MESSTXT[/red] &quot;Some text you want to put in your file\n&quot;;

When you are finished printing everything to the file, close it by closing the HANDLE.

close [red]MESSTXT[/red];

In one shot,
open ([red]MESSTXT[/red],&quot;>message.txt&quot;) or die &quot;Failed to open output file, $!\n&quot;;
print [red]MESSTXT[/red] &quot;Some text you want to put in your file\n&quot;;
close [red]MESSTXT[/red];

Also, it is a Perl convention to UPPERCASE your handles..... 'makes the code a little easier to read.

HTH


keep the rudder amid ship and beware the odd typo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top