"David L. Nicol" wrote:
>
> What if its a method of anything in an array? $_ is already
> a reference to the object on the array in for loops rather
> than a copy of it. What if we make change be not something about
> for loops, but about anything in an array?
>
> print "The index, in its array, of <<$_>> is $CORE::ARRAY_INDEX{$_}"
>
> where %CORE::ARRAY_INDEX is a very magical system-provided hash that
> tells us the index in its array of something that is in an array. It
> is often undefined; and would get tricky but definable for objects that
> can be in multiple containers at once, I'd think it would be the index
> of the item in the most recent container it was accessed from.
>
> If we are going to have arrays that can be sparse, we've pretty much got
> to keep track of this info somehow anyway, so might as well give a way
> to access it.
I sent John an email with a suggestion of modifying C<pos()> or a
similar function (because pos() already has a very different meaning) to
do this for us, as C<$#> already has meaning with regards to arrays.
More specifically:
@foo = qw(sun moon stars rain);
@bar = qw(earth water fire wind);
foreach $thingy (@foo) {
foreach $whutzit (@bar) {
print "Thingy: ", $thingy, " at ", pos(@foo), "\n";
print "Whutzit: ", $whutzit, " at ", pos(@bar), "\n";
}
}
Actually, now that I'm thinking about it, I like your idea more, but I
think we need more. :) I'd like to see a special 'hash' or array
properties that tell us
1) the first index,
2) the "current" index,
3) the last index,
4) maybe others?
$#ARY could be depreciated (another "confusing" special variable bites
the dust) and we would have a whole lot more detail regarding arrays
during array ops.
Any thoughts on this?
--
Mike Pastore
[EMAIL PROTECTED]