cjosta@tasu77.UUCP (Jonathan Sweedler) (07/02/89)
I am running perl on a Sun 3/60 with SunOS 3.5. The version is: $Header: perly.c,v 2.0.1.10 88/11/22 01:14:58 lwall Locked $ Patch level: 18 I have the following perl program: #!/usr/local/bin/perl @directory = @ARGV; --$#directory; print $#directory; This should set the array 'directory' equal to all of the command line arguments except the last one. But, the last line in the perl program always prints out '-1' and the array is left null. If I change the '--$#directory' line to be '$#directory = $#directory - 1' or if I put the line 'print $#directory' before the '--$#directory' line then the program works. It seems I must reference the '$#directory' variable before I can use change it. Am I doing something wrong here? Or is this a bug in perl? Jonathan Sweedler === National Semiconductor Israel UUCP: ...!{amdahl,hplabs,decwrl}!nsc!taux01!cjosta Domain: cjosta@taux01.nsc.com
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (07/06/89)
In article <2070@taux01.UUCP> cjosta@tasu77.UUCP (Jonathan Sweedler) writes:
: #!/usr/local/bin/perl
: @directory = @ARGV;
: --$#directory;
: print $#directory;
:
: This should set the array 'directory' equal to all of the command line
: arguments except the last one. But, the last line in the perl program
: always prints out '-1' and the array is left null.
: ...
: Am I doing something wrong here? Or is this a bug in perl?
It's a bug, and I just fixed it in 3.0.
Larry Wall
lwall@jpl-devvax.jpl.nasa.gov