gEDA-user: refdes_renum and pgskip
John Luciani
jluciani at gmail.com
Wed Jul 12 16:30:33 EDT 2006
On 7/12/06, David W. Schultz <david.schultz at earthlink.net> wrote:
> John Luciani wrote:
>
> > That line should be ---
> >
> > $pgskip = 100 unless defined $pgskip;
> >
> > (* jcl *)
> >
> > ---
> > http://www.luciani.org
> >
> >
>
> Really? I just tried it and it set pgskip to 100 even without the
> --pgskip command line option specified. $pgskip gets defined when getopt
> is invoked, or so it seems to me.
Using the :i specification you get an undefined value unless you
specify the option on the command line. If you specify the option name
without a value you get the default. There is still a condition where your
program could execute with an undefined value.
Try the little test program below with no command line options and then
try it with an option of "--test". With no command line options
the value is undefined. With "--test" the value is 100.
#--- cut here--
#!/usr/bin/perl
use strict;
use warnings;
use Carp;
use Getopt::Long;
my $Test;
GetOptions("test:100" => \$Test);
print "\$Test is undefined\n" unless defined $Test;
printf("\$Test is defined and equals %i\n", $Test) if defined $Test;
#-- cut here --
--
http://www.luciani.org
More information about the geda-user
mailing list