Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!caesar.cs.montana.edu!ogicse!schaefer From: schaefer@ogicse.ogc.edu (Barton E. Schaefer) Newsgroups: comp.lang.perl Subject: Minor error in getopt.pl and getopts.pl Message-ID: <6788@ogicse.ogc.edu> Date: 22 Jan 90 16:23:31 GMT Reply-To: schaefer@ogicse.UUCP (Barton E. Schaefer) Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR Lines: 25 I found a small problem with using "getopts.pl," which is also present in "getopt.pl" and may affect some of the other perl library functions (I haven't checked). The problem is that references to $ARGV[0] clash with resetting $[ = 1. Sample program: #! /usr/bin/perl $[ = 1; do 'getopts.pl'; Getopts("a:bc"); print "a is $opt_a, b is $opt_b, c is $opt_c\n"; I'm not sure what the correct general solution to this is. For getopt and getopts, it would be easy enough to refer to $ARGV[$[] everywhere. But perhaps a better guideline is that all library functions should use something like local($[) = 0; # Enforce local subscripting conventions (Would that work the way I think, Larry? Or would it be necessary to save, reset, and restore the global $[ ?) -- Bart Schaefer "Miserable miscreant! Question MY integrity, will you?" "I have to see some *evidence* of it before I can question it." -- Calvin & Hobbes schaefer@cse.ogi.edu (used to be cse.ogc.edu)