Chad Perrin <[EMAIL PROTECTED]> wrote: On Tue, Dec 26, 2006 at 06:59:42PM -0800, Travis Thornhill wrote: > > > Adriano Allora wrote: hi to all, > > (and a very good new year's eve). someone can tell me why this script > doesn't accept the -h flag?: > > #!/usr/bin/perl -w > > use strict; > use warnings; > use Getopt::Std; > > getopt('h'); > my $opt_h; > if($opt_h) > { > [code...] > } > > You need to declare a hash then pass the hash to the getopt() function. > This code is an example of something you can do with getopt().
Not necessarily. It can be done with scalars as easily as with hashes and, in fact, I do it like that quite often. 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. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com