How To explicitly name a hash?

P

p cooper

Ive put the Mail::SendMail inot a subroutine and get a

sub mailsendmail{
my ($from, $to, $subject, $messagebody) = @_;
my @to_emails=qw([email protected] (e-mail address removed) (e-mail address removed));
foreach $to(@to_emails)
{ %mail = ( To =>$to,
From =>$from,
Message => $messagebody);
}
}

[Sun Jan 25 20:37:09 2004] aagbi.pl: Name "main::mail" used only once:
possible typo at ./aagbi.pl line 110.

How do I explicitly name a hash ( form the mail::SendMail package) inside
the subroutine?
 
G

gnari

p cooper said:
Ive put the Mail::SendMail inot a subroutine and get a

sub mailsendmail{
my ($from, $to, $subject, $messagebody) = @_;
my @to_emails=qw([email protected] (e-mail address removed) (e-mail address removed));
foreach $to(@to_emails)
{ %mail = ( To =>$to,
From =>$from,
Message => $messagebody);
}
}

[Sun Jan 25 20:37:09 2004] aagbi.pl: Name "main::mail" used only once:
possible typo at ./aagbi.pl line 110.

How do I explicitly name a hash ( form the mail::SendMail package) inside
the subroutine?

The warning is just pointing out that you are setting the %mail hash to
different values, but not doing anything to them, which is not useful.

maybe you are forgetting a function call or something ?

gnari
 
U

Uri Guttman

pc> sub mailsendmail{
pc> my ($from, $to, $subject, $messagebody) = @_;
pc> my @to_emails=qw([email protected] (e-mail address removed) (e-mail address removed));
pc> foreach $to(@to_emails)
pc> { %mail = ( To =>$to,
pc> From =>$from,
pc> Message => $messagebody);
pc> }
pc> }

you need to declare %mail with my.

also your code formatting can be improved. don't put code on the line
with foreach's {. i won't get into where to put that { (but it should be
on the foreach line :).

uri
 
T

Tad McClellan

p cooper said:
Ive put the Mail::SendMail inot a subroutine and get a


There is no call to Mail::SendMail in the code you posted.

If you show us your (real) code, then we can help you debug it.

If you don't, then we can't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top