That is not working because $cardbody is reading the text between the
markers as plain text, not processing commands. Try this instead and see how
it works for you.

open(OUTFILE,">>$FILE_NAME"); # >> means append to the end
                              # of the file. If you want to
                              # overwrite the contents, use
                              # a single > instead.

open(TEXT,"<message.txt");    # Make it obvious you're just
                              # reading this file with "<"

while(<TEXT>) {
 print OUTFILE "$_ <BR>";     # We want to print to the file
                              # rather than STDOUT
}

close(TEXT);                  # Close the read file
close(OUTFILE);               # Close the write file


-----
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
http://www.insiteful.tv





-----Original Message-----
From: Sir Douglas Cook [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 22, 2002 1:52 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Printing a file from the print statement


How can I make the "Open File and print content statements" work from my sub
make_body
when called from sub create_file?

The output I get is
========================================
open message.txt; while () { = "." } print
========================================

The contents of message.txt is
========================================
Hello this is a message
========================================

The output I want is
========================================
Hello this is a message
========================================


The problem is how do I get this to work
========================================
sub make_body
{
$cardbody =<<__END_OF_CARD_BODY__;

    open TEXT, "message.txt";
    while (<TEXT>) {
          print "$_<BR>";
    }
    close TEXT;


__END_OF_CARD_BODY__
}
========================================

The way I print the make_body function
========================================
#Write out our HTML FILE
sub create_file
{
  open(OUTFILE,">$FILE_NAME") ;
  print OUTFILE "$cardbody\n";
  close (OUTFILE);
}
========================================


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.324 / Virus Database: 181 - Release Date: 2/14/2002

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.324 / Virus Database: 181 - Release Date: 2/14/2002


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to