in reply to read 2 array simultaneously
There are more than enough Ways To Do It already presented - I just want to point out that the first three Ways were all assuming that the two arrays were of the same size. What happens when the arrays are different lengths depends on which solution you use. Ovid's solution was the most work, but if it is possible that the arrays are different sizes, that solution is the most robust, handling all cases quite well. Note that in that solution, the shorter array, if there is one, will be treated as if it were filled with undef's - which your code would have to handle, e.g.,
printf "%s:%s %s:%s\n", $x, defined $item ? $item : '<undef>', $y, defined $element ? $element : '<undef>';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: read 2 array simultaneously
by xdg (Monsignor) on Jan 12, 2005 at 04:40 UTC |