- or download this
sub gen_iterator {
my @initial_info = @_;
...
return $current_state = $next_state;
};
}
- or download this
my $next = gen_iterator( 42 );
while ( my $item = $next->() ) {
print "$item\n";
}
- or download this
my @DNA = qw/A C T G/;
my $seq = gen_permutate(14, @DNA);
...
return join '', map { $list[ $_ ] } @curr;
};
}
- or download this
my $start = $ARGV[0] || 999999;
my $next_id = gen_id( $start );
...
$tot += $_ for split //, $chk;
return $tot % 10 == 0 ? 1 : 0;
}
- or download this
my $next_file = rotate( qw/FileA FileB FileC/ );
print $next_file->(), "\n" for 1 .. 10;
...
return $list[ $index ];
};
}
- or download this
while ( my $pass = $next_pw->() ) {
if ( unlock( $pass ) ) {
...
};
}
sub unlock { $_[0] eq 'john' }
- or download this
my @list = map { my @lines = <$_>; \@lines } @f_handles;
# becomes
...
return \@lines;
};
}
- or download this
sub infinite_evens {
my $curr = shift;
...
}
my $next_even = infinite_evens( 41 );
print $next_even->(), "\n" while 1;