On Tue, Dec 26, 2006 at 07:27:12PM -0800, Travis Thornhill wrote:
> Chad Perrin <[EMAIL PROTECTED]> wrote:    On Tue, Dec 26, 2006 at 06:59:42PM 
> -0800, Travis Thornhill wrote:
> 
> Try this instead:
> 
> our $opt_h;
> getopt('h);
> 
> That satisfies both the strict pragma and the desire to use a scalar
> varaible for your command line option.
>    
>   That's interesting. What if I have multiple options and still want to use 
> scalars?
>   Would I use multiple calls to getopt for each scalar, or could I pass them 
> all to a single call to getopt?
>    
>   - Travis.

1. I typoed, and forgot a single quote after the h above, and an s at
the end of the function name.  It should read:

  getopts('h');
  
It should not read:

  getopt('h);


2. You can do it all with a single getopts, like so:

  our ($opt_h, $opt_d);

  getopts('hd:');


That was copied directly out of a script I actually use from time to
time -- thus I'm positive that it works as written.

-- 
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"The ability to quote is a serviceable
substitute for wit." - W. Somerset Maugham

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