Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: @array in scalar context Message-ID: <7165@jpl-devvax.JPL.NASA.GOV> Date: 25 Feb 90 07:30:05 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 19 In article jv@mh.nl (Johan Vromans) writes: : This has bitten me a few times. : : Is it defined that a scalar reference to an @array yields its last : element? : : Most notably: "if @array" depends on the last element of @array being : zero or not, while I would have expected it to be equivalent to : "$#array >= $[" . It hasn't been officially defined. It returns the last element merely by analogy to the the comma operator. Does anyone actually use this to get at the last value of an array? If not, we could easily change it to return the number of elements in the array. print "ok\n" if @array == $#array - $[ + 1; Larry