Hey monks,
Updating on some chatter yesterday in the CB: I've -again- a
page I'm parsing. The parsing goes wel (with, I admit, a big ugly regex that probably could've been written much shorter), but now I want to assign a rank to each match, ie. the first match should get rank 1, the second match rank 2, ... the n
th match should get rank n.
I came up with this:
my $ranking_dgp = 0;
do {
my $gene = $1;
my $chromosone = $2;
my $score_dgp = $3;
$ranking_dgp = $ranking_dgp + 1;
push @gene_score, [ $gene, $chromosone, $score_dgp, $ranking_d
+gp ];
} while ( $text =~ m{gene\=(ENSG\d+).*?<TD>\s+(\d+|X|Y)\s+</TD>.*?
+<TD>.*?<TD>.*?<TD>.*?<TD>\s(\d.\d+)\s\<\/TD\>}gsm);
print Dumper @gene_score;
but it's one off: my first match gets rank 2. When I look at my output, I also see and understand why, but I can't think of a better way to do it.
$VAR1 = [
undef,
undef,
undef,
'1'
];
$VAR2 = [
'ENSG00000165659',
'13',
'0.738681',
2
];
$VAR3 = [
'ENSG00000184226',
'13',
'0.627447',
3
];