husker has asked for the wisdom of the Perl Monks concerning the following question:
Now if $#files is relatively small, or $num_cols is relatively large, then all the elements in @files get put into @data somewhere, and @files ends up empty. However, as $#files get higher, and/or $num_cols decreases, then when the loop finished, there are still some elements left in @files, and @data doesn't have all the files I globbed. Any clues?$num_cols = 5; @files = <*>; for (@files) { undef @bb; for ($i = 0; $i < $num_cols; $i++) { push @bb, shift @files; } push @data, [ @bb ]; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why doesn't this for loop work like I expect?
by chromatic (Archbishop) on May 18, 2000 at 00:35 UTC | |
|
Re: Why doesn't this for loop work like I expect?
by btrott (Parson) on May 18, 2000 at 00:35 UTC | |
by takshaka (Friar) on May 18, 2000 at 00:44 UTC | |
by husker (Chaplain) on May 18, 2000 at 16:54 UTC |