peschkaj has asked for the wisdom of the Perl Monks concerning the following question:

I have written a program that logs into a variety of servers and executes a ps for a few different things. It then save the output in a file named File(timestamp).log, where the filename is stored as $filename

I've been trying to incorporate code to email me the file every morning (this will be run as a cron job), and I can't seem to incorpoate the filename.

Anwyay, here is the code I am using now:

$msg = MIME::Lite->new( From =>'peschkaj@bsddev1.qwest.net', To =>'jeremiah.peschka@qwest.com', Subject =>'test message', Type =>'multipart/mixed'); $msg->attach( Type =>'TEXT', Data =>"Attached please find the attached attachment"); $msg->attach( Type =>'TEXT', Path =>'$fileName', Filename =>'AcLog.txt'; $msg->send;
jeremiah.peschka@qwest.com

Replies are listed 'Best First'.
Re: Email and filenames
by earthboundmisfit (Chaplain) on Jul 05, 2001 at 20:29 UTC
    Instead of  Path     =>'$fileName', try
    Path =>"$fileName",

    I believe the single quotes are forcing this to a literal

      Or, even better, don't use quotes if all you have is a single scalar. Quoting would bite you hard if the scalar contained a reference.

      -- Abigail

Re: Email and filenames
by Beatnik (Parson) on Jul 05, 2001 at 20:30 UTC
    try Path     =>"$fileName", instead, single quotes take literal context, if you use double quotes, the variable is interpolated properly. If you have the variable in $file instead of $fileName, use Path     =>"${file}Name",. Same for Filename.

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.