schaefer@ogicse.ogc.edu (Barton E. Schaefer) (01/23/90)
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)
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (01/23/90)
In article <6788@ogicse.ogc.edu> schaefer@ogicse.UUCP (Barton E. Schaefer) writes:
: 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 $[ ?)
That works, and I've added it to get*.pl and a few others.
Larry