Brian Volk wrote:
Hi All.

Hello,

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) {


     foreach my $html (@htmls) {
         $html =~ s/\s+\z//;
         if ($_ eq $html) {



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to