Dear Monks,br>
I am supposed to create a unique array based on a non-unique one. Problem is that I am not supposed to use hashes of built-in modules (I know, I know, but it's for educational purposes!!).
What I thought I could do is to sort the array and then somehow, since the elements would be "next" to each other, remove the duplicates.
my @array_q3=(); #create the array to store all words in the file
open INFILE3, "<file";
while( my $line3 = <INFILE3>)
{
chomp $line3;
push @array_q3, $line3;
}
close INFILE;
#sort the array so we can identify the duplicates
my @sorted_array_q3 = sort(@array_q3);
print "@sorted_array_q3\n";
but my problem is that I can't understand how I can remove the duplicates now...
Tips?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.