Hi Perl Mongers,

I'm trying to parse some command line options.

I'm expecting either no arguments, email addresses or email addresses
and file names/piped input.  This script will take the email addresses
and send the contents of a file to them, or the output of a piped
command.  So, I would expect something like this:

  # ls -la | mailer [EMAIL PROTECTED] [EMAIL PROTECTED]

or

  # ls -la | mailer

or

  # mailer [EMAIL PROTECTED] ls.out

so, I can check for no arguments with:
  if( @ARGV ) {
     #process args here
  }

and, I can match email addresses with this regex:
  /[EMAIL PROTECTED]/

I guess I'm asking for help on putting this stuff together.  When I
get done, I'd like to see a single string with the email addresses in
it, separated by commas.  I've been trying lots of stuff, but none of
it is working.  I can't seem to strip off the email addresses from the
front of @ARGV without getting hung up when I get to the end, or if
there is an (incorrectly) placed argument in the middle of addresses
that is NOT an address, like this:

  # ls -la | mailer [EMAIL PROTECTED] wrong.com [EMAIL PROTECTED]

I know I'm just missing something simple.

I did think about using one of the getopt()/getopts() modules, but I'd
rather not have to use a command-line flag/option to make this all
work.  Can you guys help me out?

--Errin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to