Next | Program Repair Shop | 290 |
Storing related items together means you manage one array instead of many
Suppose you want to discard some items?
With parallel arrays:
for (grep {$size[$_] == 0} (reverse 0 .. $#size)) { splice @size, $_, 1; splice @user, $_, 1; splice @group, $_, 1; splice @time, $_, 1; }
Better hope you didn't forget to splice one of the arrays!
With a single array, the arrays never get out of sync:
@rec = grep {$_->{size} != 0} @rec;
Next | Copyright © 2002 M. J. Dominus |