in reply to How do I remove duplicate numeric elements of an array and preserve alphabetic elements?
> preserve all alphabetic elements of the array but the duplicate numeric elements must be removed
but I think what you want is to parse the data pairwise ($number, $name) and have a unique list of names per number.
In this case I'd suggest building a hash of hashes (if original order doesn't matter). Just set
$names_per_num{$number}{$name} = 1
for each combination.
After that you'll just need to iterate over all numbers and print the keys of the sub-hash to get your desired output.
No code yet, we'd love to help you improving your attempts! :)
HTH!
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
PS: and if original order matters just use the above HoH as a %seen filter while iterating the list.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do I remove duplicate numeric elements of an array and preserve alphabetic elements?
by jzelkowsz (Novice) on Jun 07, 2018 at 13:08 UTC |