How To explicitly name a hash?

Discussion in 'Perl Misc' started by p cooper, Jan 25, 2004.

  1. p cooper

    p cooper Guest

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

    sub mailsendmail{
    my ($from, $to, $subject, $messagebody) = @_;
    my @to_emails=qw( );
    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?
    p cooper, Jan 25, 2004
    #1
    1. Advertising

  2. p cooper

    gnari Guest

    "p cooper" <> wrote in message
    news:lXUQb.9431$...
    > Ive put the Mail::SendMail inot a subroutine and get a
    >
    > sub mailsendmail{
    > my ($from, $to, $subject, $messagebody) = @_;
    > my @to_emails=qw( );
    > 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
    gnari, Jan 25, 2004
    #2
    1. Advertising

  3. p cooper

    Uri Guttman Guest

    >>>>> "pc" == p cooper <> writes:

    pc> sub mailsendmail{
    pc> my ($from, $to, $subject, $messagebody) = @_;
    pc> my @to_emails=qw( );
    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

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Jan 25, 2004
    #3
  4. p cooper <> wrote:

    > 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.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Jan 25, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucky
    Replies:
    1
    Views:
    9,113
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    May 19, 2006
  2. Bobby Chamness
    Replies:
    2
    Views:
    2,390
    Joe Smith
    Apr 22, 2007
  3. rp
    Replies:
    1
    Views:
    517
    red floyd
    Nov 10, 2011
  4. Une bévue
    Replies:
    5
    Views:
    149
    Une bévue
    Aug 10, 2006
  5. Srijayanth Sridhar
    Replies:
    19
    Views:
    612
    David A. Black
    Jul 2, 2008
Loading...

Share This Page