[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: refdes_renum and pgskip
On 7/12/06, David W. Schultz <david.schultz@xxxxxxxxxxxxx> 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
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user