I would pull out the old Data::Dumper module and use it to find where that/those undef's are. You say that it happens duing the ignore code, if that's true, than the undef's where already in @emails. grep shouldn't return an undef (in your context), so i am guessing that the undef's are creeping in during the 'regex split' or from the split just before the call to &mail().
Getting rid of the undef's is best done by not putting them in, but you can always bypass them like so:
foreach (@emails){ next unless $_; next if $_ =~ $ignore; push(@newemails, $_); }
Not the best way, that solution doesn't solve the problem, just the symptom. Use Data::Dumper on @emails once before you do anything with it, and once after your 'regex split', like so:
print Dumper \@emails;
The error could be in this line:
my ($email, $domain) = split(/\@/, $newemails[0]);
Print out the contents to see what is really there. This is one way (probablly not the best) to avoid calling &mail():
&mail($newemails[0], $domain) if $newemails[0] and $domain;
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR F--F--F--F--F--F--F--F-- (the triplet paradiddle)
In reply to (jeffa) Re: How not to pass undef variables
by jeffa
in thread How not to pass undef variables
by dru145
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |