Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!bfmny0!tneff From: tneff@bfmny0.UU.NET (Tom Neff) Newsgroups: comp.lang.perl Subject: Re: @array in scalar context Message-ID: <15204@bfmny0.UU.NET> Date: 26 Feb 90 14:24:59 GMT References: <7165@jpl-devvax.JPL.NASA.GOV> Reply-To: tneff@bfmny0.UU.NET (Tom Neff) Distribution: comp Lines: 22 >: Is it defined that a scalar reference to an @array yields its last >: element? In article <7165@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: >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; I suspect some scripts use it to get at the ONLY value of an array, e.g. open(UNAME,"/bin/uname -s|"); $uname = ; close(UNAME); In this case ($uname) = would have the same effect, but surely people do use the shorthand form. I would rather overload the length() operator in this case. -- 1955-1975: 36 Elvis movies. | Tom Neff 1975-1989: nothing. | tneff@bfmny0.UU.NET