How about something like this? It doesn't make it like GetOpt::Long, but it does handle what you want. Or you could just require that people pass an array to your subroutine and save yourself a little work. If there is only one recipient, then it's a one-element array.
############################################# my $recipients = '[EMAIL PROTECTED]'; notify_email('[EMAIL PROTECTED]',$recipients,"test","this is my body"); #my @recipients = qw([EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]); #notify_email('[EMAIL PROTECTED]',[EMAIL PROTECTED],"test","this is the body"); sub notify_email{ my ($sender,$rcpt,$subj,$body) = @_; my $recipient; if(ref($rcpt)){ if(ref($rcpt) eq 'ARRAY'){ $recipient = join(',',@{$rcpt}); }elsif(ref($rcpt) eq 'SCALAR'){ $recipient = ${$rcpt}; }else{ die "Invalid recipient parameter!\n"; } }else{ $recipient = $rcpt; } print $recipient."\n"; } ############################################# -----Original Message----- From: Olivier, Wim W [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 20, 2005 12:53 AM To: Perl Beginners (E-mail) Subject: GetOpt::Long Hi all, Is it possible to use GetOpt::Long (or something similar) in a subroutine using @_ instead of in the standard way (using @ARGV)? I want to have the following scenario, but use GetOpt in a subrouting within the main script and pass options (and values) to the subroutine. The values ($recipient, $subject, $body) must be configurable and they must be able to take multiple values, i.e. multiple recipients for a message. # Notify recipients via SMTP (email) sub notify_email { $ENV{"NTsendmail"} = $smtp; $sender = "[EMAIL PROTECTED]"; $recipient = "[EMAIL PROTECTED]"; $subject = "ALERT"; $body = join " ", @_; $mail = new NTsendmail; $mail->send($sender, $recipient, $subject, $body); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>