[comp.lang.perl] Change $#array

comeau@osc.edu (Don Comeau) (02/26/90)

I'm running Perl 3.0 pl 8 on Sun-3s.

The following script produces the unexpected output -1.

#!/usr/hydrogen/gnu/bin/perl
@array = (0,1,2,3,4,5,6);
# $#array;  # uncomment this line for expected behaviour
$#array -= 2;
print "elements in array -- ",$#array,"\n";

If the indicated line is uncommented, the script behaves as expected.

Feel free to let me know if I'm doing something stupid or I had my
eyes closed while reading the manual.

Don Comeau                      comeau@hydrogen.mps.ohio-state.edu
Dept of Chemistry               comeau@ohstpy.bitnet
Ohio State University           614-292-9431
-- 
Don Comeau                                      comeau@osc.edu
Ohio Supercomputer Center                       doncmh@ohstpy.bitnet
1224 Kinnear Road                               614-292-6038
Columbus  OH  43212-1154