in reply to How do I remove duplicate numeric elements of an array and preserve alphabetic elements?

This puzzles me,

> 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.

  • Comment on Re: How do I remove duplicate numeric elements of an array and preserve alphabetic elements?
  • Download Code

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
    Rolf: Thank you very much for your reply! I will read the link you mentioned. I have found Perl Monks to be very helpful!