[Za-pm] GetOpt::Long problem

Olivier, Wim W Wim.Olivier at standardbank.co.za
Thu Apr 21 02:26:00 PDT 2005


Hi guys,

Can anyone assist and see the problem I've got here please?


I used the method below (local @ARGV = @_;) to get the values of @_ into
@ARGV for the use of Getopt::Long.  It appears to be working fine like that.
I now have another problem with, it appears, syntax. The IF statement is
part of a block in the switch statement, but there is nothing wrong with the
switch statement itself, as there are many identical if statements there. If
I comment out this if statement, I don't get the error anymore.  An clues as
to the correct syntax???

I run the subroutine as follows:

if ($conf{'check_email'} =~ 'ON')
   { notify_email -r Wim.Olivier at standardbank.co.za -r
testuser at standardbank.co.za -s "Subject line" -b "Message body" };


But I get the following error when it executes:

Bad switch statement (problem in the code block?)



Please see the code below:

============================================================================

# Notify recipients via SMTP (email)
# Usage: notify_email -r user1 at a.com -r user2 at b.com -s "Subject line" -b
"Message body"
sub notify_email {
  local @ARGV = @_;   # Get the sub's params into the master param array for
GetOpt::Long
  $ENV{"NTsendmail"}  = $conf{'smtp'};
  $sender             = $conf{'smtpsender'};

  my @recipients;
  my @subject;
  my $body;
  GetOptions ("r=s"  => \@recipients,      # -r user1 at a.com -r user2 at b.com
-r user3 at c.com
              "s=s"  => $subject,          # -s "This is the subject
line..."
              "b=s"  => $body);            # -b "This is the message
body..."
  #@recipients = split(/,/,join(',', at recipients));
  #$subject    = join(" ", @subject);
  #$body       = join(" ", @body);

  foreach $recipient (@recipients) {
    print "$sender, $recipient, $subject, $body\n";
    $mail = new NTsendmail;
    $mail->send($sender, $recipient, $subject, $body);
  }

}
============================================================================

__________________________________________________________________________________________________________________________________

Standard Bank Disclaimer and Confidentiality Note

This e-mail, its attachments and any rights attaching hereto are, unless the context clearly indicates otherwise, the property of Standard Bank Group Limited and/or its subsidiaries ("the Group"). It is confidential, private and intended for the addressee only. 

Should you not be the addressee and receive this e-mail by mistake, kindly notify the sender, and delete this e-mail, immediately and do not disclose or use same in any manner whatsoever. 

Views and opinions expressed in this e-mail are those of the sender unless clearly stated as those of the Group. The Group accepts no liability whatsoever for any loss or damages whatsoever and howsoever incurred, or suffered, resulting, or arising, from the use of this email or its attachments.

The Group does not warrant the integrity of this e-mail nor that it is free of errors, viruses, interception or interference. 

Licensed divisions of the Standard Bank Group are authorised financial services providers in terms of the Financial Advisory and Intermediary Services Act, No 37 of 2002 (FAIS).

For information about the Standard Bank Group Limited visit our website http://www.standardbank.co.za
___________________________________________________________________________________________________________________________________


More information about the Za-pm mailing list