develooper Front page | perl.beginners | Postings from September 2009

text html from file to a scalar and mail

Thread Next
From:
John Plum
Date:
September 12, 2009 01:33
Subject:
text html from file to a scalar and mail
Message ID:
joniplum-80C0C6.09322012092009@ger.gmane.org
HI Folk,

May I introduce myself, John Plumridge, London, UK. 
      - I'm still in awe of this whole creation we're in.

Nice to meet you.


I have a reason of course, for approaching you, via my MTNews 'console'.
What a great application!

MY problem is obtaining and passing text/html from file to a scalar 
variable to be printed to mail, (using MIME::Creator).

Unfortunately I get: 'printFile(FileHandle=GLOB(0x84b66b8))'

 The reference assigned to the scalar variable is from a FileHandle sub 
routine. However, with a similar reference to sub routines, i.e. 
OrderFromForm_html(),  I get the output printed to mail without a 
problem. That sub routine  is perl processed form data passed from a 
preceding visible page in browser - 'form.html') 

With mixed success then, I'v worked hard at this. Take a look:

###----signature (html)from external file----###

my $signature_file = "/path_to/signature.html";

use FileHandle;
   my $signature = new FileHandle;
      $signature->open("<$signature_file")or die "Could not open 
file\n";   


sub printFile($) {
 my $fileHandle = $_[0];
    while (<$fileHandle>) {
        my $line = $_;
        chomp($line);
        print "$line\n";
$fileHandle->close(); # automatically closes file
    }
}



#---Assemble/concatenate references in both ascii and html, to make full 
confirmatory message bodies with order details---

$scalar_sig = "\printFile($signature)";

my $customer_msg_html = $customer_msgStart_html  . OrderFromForm_html() 
. $customer_msgEnd_html . $scalar_sig;

#---- Create Message ---

    Email::MIME->create(
        attributes => {
            content_type => "text/html",
            charset      => "UTF-8",
            encoding     => "quoted-printable",
            format       => "flowed",
        },
        body => $customer_msg_html,
    ),


################
So, as I suggested, the message arrives with the body message all nicely 
concatenated , except for the $scalar_sig variable, which is moissing: 
and I have the 'printFile(FileHandle=GLOB(0x84b66b8))' as a nice fat 
error.

I would really appreciate your help, and outright suggestions, as I have 
struggled with is and tests for three days now, (but I have got a lot of 
the work done (: -  though this problem has me stumped)!

John P.

-- 
--
http://jakbop.nfshost.com


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About