[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:
According to my copy of "Programming Perl",

"If you don't initialize your variables, they automatically spring into
existence with a null value that means either '' or 0 as necessary."

Which is why my change works as expected. If the --pgskip command line
option is not specified, $pgskip springs into being with a value of zero.

If you explicitly declare and initialize your variables you can use the "strict" pragma which may catch additional errors (see the "Pragmatic Modules" chapter in "Programming Perl" ;-). I always use "strict" and the "-w" switch which is why I suggested explicitly setting the variable.

I believe that the following code will also work (the way you want it to).

&GetOptions(("help" => \&usage,
	     "nocopy" => \$nocopy,
	     "pgskip:100" => \$pkgskip,
	     "verbose" => \$verbose,
	     "version" => \&version
	     ));

$pkgskip = 0 unless defined $pkgskip;

(* jcl *)

P.S. I noticed that option name is pgskip and the variable name is $pkgskip.
You may want to change one or the other.

--
http://www.luciani.org


_______________________________________________ geda-user mailing list geda-user@xxxxxxxxxxxxxx http://www.seul.org/cgi-bin/mailman/listinfo/geda-user