🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #51

bug in perl concerning arrays?

#51
From: Jonathan Sweedler
Date: Sun, 02 Jul 1989 06:50
24 lines
1360 bytes
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
Technical Details
Message-ID: <2070@taux01.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!decwrl!nsc!taux01!tasu77!cjosta

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!decwrl!nsc!taux01!tasu77!cjosta
From: cjosta@tasu77.UUCP (Jonathan Sweedler)
Newsgroups: comp.sources.bugs
Subject: bug in perl concerning arrays?
Message-ID: <2070@taux01.UUCP>
Date: 2 Jul 89 06:50:51 GMT
Sender: netnews@taux01.UUCP
Reply-To: cjosta@tasu77.UUCP (Jonathan Sweedler)
Organization: National Semiconductor (IC) Ltd, Israel
Lines: 24