[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Counting Words



On Tue, May 25, 1999 at 08:37:24AM -0400, Dick Munroe wrote:
> Try;
> 
> local @words = split(" ", $a) ;
> 
> return $#words + 1 ;
> 
> $#arrayName returns the last index number of the array, adding 1 to it
> gives you the number of elements in the array (assuming 0 based indexing).

Hmm...

a) why local() instead of my()?

b) split() defaults to whitespace.

c) the scalar value of @words is the # of elements, so you don't
really need the $#words + 1 construct.

*shrug*

TMTOWTDI...

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
... we didn't know what the hell we were doing, but we did it loud.
	- Andy Partidge on early XTC

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org