ok, maybe way off here but I'll give it a try

#!/usr/bin/perl # use Data::Dumper; my $datafile = "test.dat"; my %finalQ = (); open(FH, "<$datafile") || die ; my %combined = (); while( <FH> ){ chomp; my ($key,$value) = sort (split(/\t/,$_)); $combined{$key}=$value; } my %count = (); my %reverse = reverse(%combined); foreach my $key (sort %combined) { print "$key => $combined{$key}\n"; if ( exists $reverse{$key} ) { $count{"$key\t$reverse{$key}"}+=2; print "$key => $reverse{$key} :: match\n"; } else { $count{"$key\t$combined{$key}"}++; } } print Dumper(%count);

output

$VAR1 = '       ';
$VAR2 = 4;
$VAR3 = 'NP_05  NP_04';
$VAR4 = 2;
$VAR5 = 'YP_01  NP_03';
$VAR6 = 2;
$VAR7 = 'NP_03  NP_02';
$VAR8 = 4;
$VAR9 = 'NP_02  NP_03';
$VAR10 = 1;
$VAR11 = 'NP_04 NP_05';
$VAR12 = 1;

In reply to Re: help needed in modifying the code for counting possible combinations by gman
in thread help needed in modifying the code for counting possible combinations by BhariD

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.