I get a syntax error using @#ITEMS.  However, $#ITEMS does equal 2 (in your
example).

$#array is the index of the last element in the array.  It is documented, I
have seen it many times, I just can't seem to find it right now.  I think it
was more useful in the past when you could set the starting index of arrays
to something other than zero.  I think you still can, but its discouraged.
I promptly forgot how to do that because it seems like such a bad idea.

Patrick McCabe


----- Original Message -----
From: Phil Plumbo <psp at printwareinc.com>
To: <tclug-list at mn-linux.org>
Sent: Friday, July 14, 2000 3:24 PM
Subject: [TCLUG:19613] [OT] perl boogage?


> I ran across a curiosity in a perl program today, which can be explained
> like so:
>
>  @ITEMS = (0, 1, 2);
>  print @#ITEMS;                # prints "2";
>
>
> So if you wedge a '#' into an array name, it means "the length of the
array,
> less 1" (Oh, of course!). The guy was using it as a loop limit.
>
> I couldn't find anything on this in any of the perl books I own... is this
a
> documented feature of the language, or just a fetid schbat of boogage?
>
> To me, it looks suspiciously like a fetid schbat of boogage.
>
> Phil Plumbo.
>
> Or, perhaps, a turgid wad of hell-snot.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe at mn-linux.org
> For additional commands, e-mail: tclug-list-help at mn-linux.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tclug-list-unsubscribe at mn-linux.org
For additional commands, e-mail: tclug-list-help at mn-linux.org