develooper Front page | perl.beginners | Postings from February 2002

OO perl problem

Fitzpatrick, Matthew
February 6, 2002 07:48
OO perl problem
Message ID:
Hello, my name is matthew fitzpatrick, and i am having some small difficulty in my implimentation of Mail::Sender. 

The problem is that when there are multiple calls to $sender->MailFile or $sender->MailMsg in my loop, only the first match for each MailFile or MailMsg actually gets sent with the email.  I instantiate and close the $sender reference with each iteration of the loop, i don't know why it's not working past the first call.

I have attached a snippet of code:

use Mail::Sender;

# here would be a DBI query that fetchrow_array()'s a series
# of unique message identifiers
while (@arr_uniqID=$sth_uniqID->fetchrow_array())
# the problem is in the following subroutine called from the above loop.  
# If the subroutine is iterated through n times in the loop,
# only the first MailFile method in all 50 iterations causes a message to be sent, and 
# only the first MailMsg gets sent.  I don't know why 
# this is the case since I declare $sender, and call Close() in the subroutine

sub emailRequests($$)
        my $uniq_id=shift(@_);
        my $emailAddr=shift(@_);

        my $sender = new Mail::Sender
                smtp => '',
                from => ''

        my $str_attachFiles='';

        print "\tMessage Matched: $uniq_id\n";

        my $str_selectMsg="select message from messages where uniq_id='$uniq_id'";
        my @arr_msgContent=$sth_selectMsg->fetchrow_array();

        my $str_selectURL="select url from attachments where uniq_id='$uniq_id'";
        while (my @arr_selectURL=$sth_selectURL->fetchrow_array())

        if ($str_attachFiles)
                        subject=>'Sirios READER Search Results',
                        subject=>'Sirios READER Search Results',
} Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About