Perhaps you missed
    <http://www.stonehenge.com/merlyn/LinuxMag/col30.html>, putting an
    iterator behind a tied hash, giving you "each" as a single
    iteration, or "keys" to get them all.
    Yet Another Way. :)

OK, well if you're using a hash to iterate, then it's perhaps a
different type of iterator.  In Maptastic there is a map_each(&@)
method, which sets @_ to (each %hash) in the block.  This would work
with your tied hash approach, as the input would be ->isa("HASH").

However, I suppose that using the scalar form of `each', returning
just the key, would be the appropriate thing to use for map variants
that expect singular items.

So we've got:

Blessed objects:
    $_->__next__    (Object::Iterate)
    $_->get_next    (SPOPS-style)
    $_->next        (Tangram::Cursor, File::Iterator,
                       Data::Iterator::EasyObj, etc)
Unblessed:
    $_->()          (MJD-style, his hybrid blessed closures can be
                     expected to ->can() one of the above)
    scalar(each %$_)

Hmm, for completion, what about arrays?

I can see two possible semantics for arrays as iterators;

   shift @$_    while (@$_)

   $_->[$i++]   while (exists $_->[$i]);

I think the latter is better, though it doesn't work with sparse
arrays.  Caveat emptor?
-- 
Sam Vilain, [EMAIL PROTECTED]

  Things are more like they are now than they ever were before.
DWIGHT D EISENHOWER

Reply via email to