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

I am using a module to email file attachments via sendmail. The format for multiple attachments is:

'/dir/of/file/filename1.txt', '/dir/of/file/filename2.txt'

My filepath is static and defined as a variable, $file_path.

The file name is read in from a flatfile, split, and built into arrays. I end up with the following to make my path/file:

$file = "'" . $file_path . $fields[6] . "', ";

I am printing this in the email message, looks like this: '/my/file/path/myfile/txt',

If I copy this out of the email and use it literally in the script my file sends, but if I use the variable $file it doesn't. I can make one file send by losing the ' and , but I can't make multiple files send this way. If I use \$file and print it to email it prints this: 'SCALAR(0x8111390)',

I've tried every combination of ", ' \' you name it... What does all this mean? Please help! Thanks, Cliff

Update: added <code> tags, larsen

Replies are listed 'Best First'.
Re: Scalar value??
by techwolf (Novice) on May 13, 2002 at 21:01 UTC
    Alrighty,

    I'd really need to know if you have multiple files, but this should get you started on the right path:

    ## early on.. $filepath = '/dir/of/file/'; ## in your foreach/while for your file push(@files,$field6); ## later on... $d = join("','", @files); $d = "'" . $d . "'";
    See if that works for you. You can probably just send the filenames as variables to the module though:

    $file1 = '/dir/of/file/filename1.txt'; $file2 = '/dir/of/file/filename2.txt'; ## then send both variables to the module: $file1,$file2

    HTH.

    -techwolf

Re: Scalar value??
by Android 18 (Novice) on May 13, 2002 at 20:48 UTC
    I would recommend using the 'catfile' function in the 'File::Spec' module to do your directory/file concatenations. It's just less error prone.

    Once bread becomes toast, it can never be bread again.