Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: help needed in modifying the code for counting possible combinations

by gman (Friar)
on Oct 30, 2009 at 20:16 UTC ( [id://804211]=note: print w/replies, xml ) Need Help??


in reply to help needed in modifying the code for counting possible combinations

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;
  • Comment on Re: help needed in modifying the code for counting possible combinations
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://804211]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-20 15:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found