#!/usr/bin/perl # ARGV[0] is the input file name (first parameter) #print $ARGV[0]; open(MYF, "<$ARGV[0]"); @lines = ; close(MYF); $values = ""; $summations = ""; $arrIDs = ""; $ID = 0; foreach my $line (@lines) { @values2 = split(/\,/, $line); $sum = 0; $val = 0; foreach my $val (@values2) { #print $val; #print "val is $val\n"; $sum = $sum+$val; } #print "sum: $sum\n"; # First check to see if the summation is not already in the list. $no_go = 0; foreach my $pre (@summations) { if ($pre == $sum) { $no_go = 1; } } if (!$no_go) { push(@summations,$sum); push(@arrIDs, $ID); } $ID=$ID+1; } @s = sort @summations; #{$b <=> $summations} @summations; for ($i = 0; $i < 50; $i++) { #print "" . $s[$i] . "\n"; # Which graph ID is this associated with? # summations[i] is the sum of row with rowID of: arrIDs[i] # s has been sorted though. So let's go back through it, since there are only unique sums. $k = 0; foreach my $sumlets (@summations) { if($s[$i] == $sumlets) { # Ok, the graph is $arrIDs[$k] $blah = $arrIDs[$k]; if($blah < 10) { print "candidates00$blah.dsm\n"; } elsif ($blah < 100) { print "candidates0$blah.dsm\n"; } else { print "candidates$blah.dsm\n"; } } $k++; } #$j = 0; #foreach my $line (@lines) { # @values2 = split(/\,/, $line); # $sum = 0; # $val = 0; # foreach my $val (@values2) { # $sum = $sum+$val; # } # if($sum == $s[$i]) { # if ($j < 10) { print "\tcandidates00$j.dsm\n"; } # elsif ($j < 100) { print "\tcandidates0$j.dsm\n"; } # else { print "\tcandidates$j.dsm\n"; } # } # $j++; #} }