You could try a more complex data structure.
A something of somethings of arrays should do the trick, such as an array of arrays of arrays:-
@id = (
[
[ ], # id1-0
[ ], # id2-0
[ 0, 0, 0 ], # id3-0
],
[
[ 90, ], # id1-1
[ 70, ], # id2-1
[ ], # id3-1
],
# ...
);
...or an array of hashes of arrays:-
@id = (
{
id3 => [ 0, 0, 0 ],
},
{
id1 => [ 90, ],
id2 => [ 70, ],
},
# ...
);
...or even a hash of hashes of arrays:-
%id = (
0 => {
id3 => [ 0, 0, 0 ],
},
1 => {
id1 => [ 90, ],
id2 => [ 70, ],
},
# ...
);
Without knowing more about your input data, it's hard to say which of those will best suit your needs (or if something else is more appropriate or possible), but the of arrays part will at least do away with the issue of duplicates.
Edit: Fixed typos in examples.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.