Try this code:
#!/usr/bin/perl use warnings; use strict; # firstly, put all data in hashes because it's easier to look for data + in a hash my @input = ({},{}); # 2 hash references my @output; while (<>) { # this means: <STDIN> and/or filenames from @ARGV if (/^>([^\s]+)(\s+)?([^\s]+)?$/) { ++$input[0]->{$1}; # first match is an element of 1st +column defined $3 && ++$input[1]->{$3}; # third match might n +ot exist and belongs to 2nd column } } # secondly, loop over first hash searching for elements in second hash for (keys %{$input[0]}) { unless (exists ${$input[1]}{$_}) { push @output,$_; } } print join "\n",@output;
Sorry if my advice was wrong.

In reply to Re^5: NON Common Elements between two columns by aitap
in thread NON Common Elements between two columns by Giorgio C

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, 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:
    & &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.