develooper Front page | perl.beginners.cgi | Postings from April 2008

Re: Sendmail

Thread Previous | Thread Next
From:
Mike Williams
Date:
April 10, 2008 06:12
Subject:
Re: Sendmail
On Thu, Apr 10, 2008 at 12:41 AM, Perl CGI script enhancer <
deepan.17@gmail.com> 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
deepan.ignatius@gmail.com

Mike


Thread Previous | Thread Next


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About