in reply to Re^3: Designing a DWIMish interface for generator function
in thread Designing a DWIMish interface for generator function
use strict; use warnings; { my %lists; sub deal { my $aref=shift; my $id= \$_[0]; #print $aref,$id; $lists{$id}=$aref if (! exists $lists{$id} ); if (@{$lists{$id}}){ for(@_) { $_=shift @{$lists{$id}}; } return 1; } else { delete $lists{$id}; return 0; } } } $\="\n"; #--------- here we go while (deal [1..9] => my ($a,$b,$c) ){ print $a,$b,$c; while (deal [a=>1,b=>2] => my ($a,$b) ){ print $a,$b; } } #--------- print "EXIT"; __DATA__ 123 a1 b2 456 a1 b2 789 a1 b2
But I have to admit that till now I haven't thought about last, that's indeed a problem...
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Designing a DWIMish interface for generator function
by ikegami (Patriarch) on Feb 01, 2010 at 05:53 UTC | |
by LanX (Saint) on Feb 01, 2010 at 11:12 UTC |