Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Help sending with MIME::Lite

by TedPride (Priest)
on Sep 17, 2004 at 20:30 UTC ( [id://391889]=note: print w/replies, xml ) Need Help??


in reply to Help sending with MIME::Lite

You need to read the data into another variable and feed it instead of the file name. You can do this in a number of ways, including read and open / <INP> / close and so on, and this may not be the most efficient method due to my lack of experience, but here we go:
my $scratchtps="/usr/local/log/sctps"; sub mailme { open (INP, $scratchtps) || die $!; my $content = join('', <INP>); close(INP); my $msg = MIME::Lite->new( From => 'EDM01 <root@edm01.ohnet>', To => 'Derek Smith <dbsmith@ohiohealth.com>', Subject => "EDM Return Tapes", Data => $content ); $msg->send; } if ( -s $scratchtps ) { &mailme; }
Questions to ask:
1. Is there a command for reading a file into a string variable?
2. Is there a way to output an entire array without having to join first, as I'm doing above?

Replies are listed 'Best First'.
Re^2: Help sending with MIME::Lite
by etcshadow (Priest) on Sep 17, 2004 at 20:38 UTC
    Questions to ask:
    1. Is there a command for reading a file into a string variable?
    Well, there's File::Slurp, which is almost too simple to be a module... it's as easy as:
    my $contents = do { local (@ARGV,$/) = ($filename); <> };
    or other, less obfuscated ways, which all involve locally undefing the input record separator $/.

    2. Is there a way to output an entire array without having to join first, as I'm doing above?
    Not really... if you want to slap an array of strings together into one long string, that's what join is for. I mean, you could have a loop which concatenates the values together, but join is simpler and (I'm guessing) faster. Of course, as mentioned above, by setting $/ to undef, you won't divide the text up in the first place, so it wouldn't matter.
    ------------ :Wq Not an editor command: Wq
Re^2: Help sending with MIME::Lite
by drock (Beadle) on Sep 17, 2004 at 21:49 UTC
    not working, but thanks anyway!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://391889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-23 07:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found