Hi All.
I'm having trouble getting my program to work with the files that contain
trailing white spaces... I've been reading chapters 8 "More about Reg exp"
and 9 "Using Reg exp" and I think I'm close... I can get the program to
work if the txt files do not have trailing spaces but they are coming from a
mini-frame that uses field length (30) and the files are right justified.
For example:
(my $orders_dir)
File 121212.TXT ...contains
12345.html <spaces> CR
12346.html <spaces> CR
Here is the piece I'm having trouble w/
foreach my $html (@htmls) {
if ($html =~ /^($_)\s*/) {
my $msg = MIME::Lite->new (
This actually does the same thing as this piece of code... which works only
if the files do not have trailing spaces...
foreach my $html (@htmls) {
if ($_ eq $html) {
my $msg = MIME::Lite->new (
Here is the entire program..
#!/usr/bin/perl
use strict;
use warnings;
use MIME::Lite;
use Net::SMTP;
# directory contains html files
my $html_dir = "M:";
opendir(DIR, $html_dir) or die "Can't open the $html_dir: $!\n";
# read file/directory names in that directory into @htmls
my @htmls = readdir(DIR) or die "Unable to read current dir:$!\n";
closedir(DIR);
# directory contains .txt files w/ lines that match a html file
my $orders_dir = "I:/MSDSIN";
opendir (ORDERS, $orders_dir) or die "Can't open $orders_dir: $!";
# read all the item numbers(+html) in all the .txt files and
# load @ARGV for <> operator
@ARGV = map { "$orders_dir/$_" } grep { !/^\./ } readdir ORDERS;
while (<>) {
chomp;
# email information
my $from_address = '[EMAIL PROTECTED]' <mailto:'[EMAIL PROTECTED]'> ;
my $to_address = '[EMAIL PROTECTED]' <mailto:'[EMAIL PROTECTED]'> ;
my $mail_host = 'smtp.bvolk.com';
my $message_body = "Attached is the msds for $ARGV";
foreach my $html (@htmls) {
if ($html =~ /^($_)\s*/) {
# if ($_ eq $html) {
my $msg = MIME::Lite->new (
From => $from_address,
To => $to_address,
Subject => $ARGV,
Type =>'multipart/mixed'
) or die "Error creating multipart container: $!\n";
$msg->attach (
Type => 'TEXT',
Data => $message_body,
) or die "Error adding the text message part: $!\n";
$msg->attach (
Type => 'application',
Path => "$html_dir/$html",
Disposition => 'attachment'
) or die "Error adding $html $!\n";
MIME::Lite->send('smtp', $mail_host, Timeout=>60);
$msg->send;
}
}
}
closedir (ORDERS);
___END
Any help would be greatly appreciated! Thanks!
Brian Volk
HP Products
317.298.9950 x1245
<mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]