Your skill will accomplishwhat the force of many cannot PerlMonks

### How To: Make An Iterator

by Limbic~Region (Chancellor)
 on Apr 25, 2005 at 17:20 UTC Need Help??

sub gen_iterator {
my @initial_info = @_;
...
return \$current_state = \$next_state;
};
}

my \$next = gen_iterator( 42 );
while ( my \$item = \$next->() ) {
print "\$item\n";
}

my @DNA = qw/A C T G/;
my \$seq = gen_permutate(14, @DNA);
...
return join '', map { \$list[ \$_ ] } @curr;
};
}

my \$start = \$ARGV[0] || 999999;
my \$next_id = gen_id( \$start );
...
\$tot += \$_ for split //, \$chk;
return \$tot % 10 == 0 ? 1 : 0;
}

my \$next_file = rotate( qw/FileA FileB FileC/ );
print \$next_file->(), "\n" for 1 .. 10;
...
return \$list[ \$index ];
};
}

while ( my \$pass = \$next_pw->() ) {
if ( unlock( \$pass ) ) {
...
};
}
sub unlock { \$_[0] eq 'john' }

my @list = map { my @lines = <\$_>; \@lines } @f_handles;
# becomes
...
return \@lines;
};
}

sub infinite_evens {
my \$curr = shift;
...
}
my \$next_even = infinite_evens( 41 );
print \$next_even->(), "\n" while 1;

Create A New User
Node Status?
node history
Node Type: perltutorial [id://451278]
help
Chatterbox?
 [marto]: use libPD on Android/IOS, route to something listening on the pi :P [marto]: libpd [marto]: OSC [Discipulus]: choroba i'm just behind you at 100 points

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2017-10-17 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My fridge is mostly full of:

Results (225 votes). Check out past polls.

Notices?