in reply to Why doesn't this for loop work like I expect?
That should fix your problem, cause it'll only loop as long as there are elements in @files. Whereas yours was actually looping *over* @files, which is a different thing, and not recommended if you're going to be modifying @files (which you did, by using shift).while (@files) { ...
Alternatively, though, you may want to try using splice:
splice grabs chunks of an array (and can also replace those chunks w/ a list) and increases/decreases the size of the array as necessary. Sounds good for your particular use.push @data, [ splice @files, 0, $num_cols ] while @files;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Why doesn't this for loop work like I expect?
by takshaka (Friar) on May 18, 2000 at 00:44 UTC | |
|
RE: Re: Why doesn't this for loop work like I expect?
by husker (Chaplain) on May 18, 2000 at 16:54 UTC |