Re: Sendmail

[email protected] ("Mike Williams")
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
On Thu, Apr 10, 2008 at 12:41 AM, Perl CGI script enhancer <
[email protected]> wrote:

> my $email = populateEmail("test");
> print $email;
>
> When i a using the above code it results in "No recipient address
> found in header" and when i replace ${email} with "dpr.17\@gmail.com"
> ie
>
> To : dpr.17\@gmail.com it works fine.
>
> populateEmail function's code is available below:
>
> populateEmail {
>      if(lc($_[0]) eq "test") {
>             return ("deepan.ignatius\@gmail.com");
>      }
> }
>
> Can anyone spot the bug?
>
> Well, I didn't see it at first, so I cut and pasted a snippet of your code
into a local file, ran it at the command line and got:
Undefined subroutine &main::populateEmail called at ./cgi_list_bug.pl line 6

What you posted was missing 'sub' before populateEmail

#!/usr/bin/perl
#
use strict;
use warnings;

my $email = populateEmail("test");
print $email, "\n";

sub populateEmail {
    if(lc($_[0]) eq "test") {
        return ("deepan.ignatius\@gmail.com");
    }
}
# output from test ...
$ ./cgi_list_bug.pl
[email protected]

Mike
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.