Damian Conway wrote:
> 
> What you want is:
> 
>         %newhash = map {yield $_; transform($_)} %oldhash;
> 
> This flattens the %oldhash to a sequence of key/value pairs. Then the
> first time the map block is called (i.e. on a key) it immediately
> returns the key. The second time, it resumes after the C<yield> and
> transforms the value. That resets the block so that for the next
> iteration (another key) it returns at once, then tranforms the second
> value, etc., etc.
> 
> I'll definitely add *that* in to RFC 31.


Right, C<yield> ends the current subroutine call by "returning" the
value, so it wouldn't be a way of generating multiple items per source item.

I wonder if something like this could be used to create the merge/unmerge
functions (or whatever they're called today)

        foreach @bigarray {
                yield (push @array1, $_);
                yield (push @array2, $_);
                yield (push @array3, $_);
                push @array4, $_;
        };



-- 
                          David Nicol 816.235.1187 [EMAIL PROTECTED]
           perl -e'map{sleep print$w[rand@w]}@w=<>' ~/nsmail/Inbox

Reply via email to