Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!ncoast!allbery From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.lang.perl Subject: Re: $# question Message-ID: <1990Nov23.184701.11478@NCoast.ORG> Date: 23 Nov 90 18:47:01 GMT References: Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.lang.perl Organization: North Coast Public Access *NIX, Cleveland, OH Lines: 49 As quoted from by roy%cybrspc@cs.umn.edu (Roy M. Silvernail): +--------------- | $#foo, in this case, will be 4, and therin lies the confusion. The array is | obviously 5 elements long. Wouldn't $# make more sense if it were to | point to the array element _past_ the last element assigned? (i.e. to | the null element past '5' in the above example) Then it could be used | directly as an indication of size, and as well, you could do +--------------- Using $# usually means you aren't doing it the Perl way. To wit: +--------------- | while () { | @foo[$#foo] = $_; | } +--------------- while ( { push(@foo); } is faster and easier to read (once you're used to Perl, at least): "while you can get something from , push it onto array `foo'". +--------------- | It's possible that this has been addressed in later patch-levels, but | until PL41 comes around for DOS, I'm stuck at PL18. [ :-( ] +--------------- I think it's been as it is since Perl v1; as a result, it's a bit late to change it. I suspect a large number of scripts would break resoundingly. +--------------- | (not-quite-related question: how does one unlink() a file not in the | current directory? I've tried explicit pathnames with both / and \ as | separators, but to no avail) +--------------- Have you tried doubling the \? Remember that \ is meaningful to Perl as an escape character, so to get one into a string you must say something like '\\dos\\command.com'. (I assume the MS-DOS version of Perl doesn't use the old MS-DOS v1.25 calls!) ++Brandon -- Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440 Internet: allbery@NCoast.ORG Packet: KB8JRR @ WA8BXN America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88] uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY