On 2012-12-15 06:13, timothy adigun wrote:

Using Dr., Ruud's data. This is another way of doing it:

[solution using a hash]

Realize that with keys(), the input order is not preserved.

Another difference is that when a key comes back later,
the hash solution will collide those, which is either
wanted of unwanted.

So it all depends on what the *real* specifications are.

A combined approach is to use the hash, and also push
new keys in a side array. Then you can use that array
to restore order later.

The hash solution is not good with huge files.

The code pattern I showed, is most used in map-reduce,
where the input file is ordered (at least) on key,
so you don't have to check that anymore.

--
Ruud


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to