Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Ah, I did it using the following code:
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 INFILE3; #sort the array so we can identify the duplicates my @sorted_array_q3 = sort(@array_q3); my @unique_array; #iterate through the sorted array and check for unique elements foreach my $element ( @sorted_array_q3 ) { if ( ! grep( /$element/, @unique_array ) ) { push( @unique_array, $element ); } } #print the unique elements in the file clean.acc\n"; open OUTFILE3, ">unique_codes"; for (my $m=0; $m<=$#unique_array; $m++) { print OUTFILE3 $unique_array[$m]."\n"; } close OUTFILE3;

My problem here is with grep, since I seem to miss one element... The element has the code J00148 and apparently there is a conflict with another element, namely AJ001487.
What must I add in my grep conditional?

In reply to Re: Create unique array --the hard way! by Anonymous Monk
in thread Create unique array --the hard way! by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (4)
    As of 2020-08-13 00:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Which rocket would you take to Mars?










      Results (68 votes). Check out past polls.

      Notices?