I have an array in Perl:
my @my_array = ('one','two','three','two','three');
How do I remove the duplicates from the array?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do something like this as demonstrated in perlfaq4:
Outputs:
If you are aiming for universality, you should take a look at the
uniqfunction. It is included in the core moduleList::Utilas of Perl v5.26.0 (for older versions, useList::MoreUtils). This function differs from the above sketch in that it treatsundefas a separate value, different from'', and does not issue a warning.