From: Ramprasad A Padmanabhan <[EMAIL PROTECTED]>
> Suppose I have a huge array of filenames and I want to move them I
> would like to move 1 chunk at a time on 'n' elements
>
> How Can I efficiently do it ?
>
> something like
>
> @allfiles = (....) # 10000 files
> @smallchunks = split_to_chunks(@allfiles,100);
> # This function is what I want to write
>
> foreach (@smallchunks) {
> my $filelist = join(" ",@{$_});
> ....
> .....
> }
my $chunk_size = 100;
for( my $i = 0; $i * $chunk_size <= $#allfiles; $i++) {
my $filelist = join( " ", @allfiles[$i*$chunk_size ..
(($i+1)*$chunk_size - 1)]);
...
}
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]