BioGeek,
I really hate coding anything web related. I force myself to though when I get a scratch, so that I can do it when I really need to. Have a look at:
#!/usr/bin/perl use strict; use warnings; use HTML::TableContentParser; use HTML::TokeParser::Simple; use WWW::Mechanize; use Data::Dumper; my $mech = WWW::Mechanize->new( autocheck => 1 ); $mech->get( 'http://nexus.ugent.be/jeroen/bc.html' ); my @gene_score; my $table = HTML::TableContentParser->new()->parse( $mech->content() ) +; for my $rank ( 1 .. $#{ $table->[0]{rows} } ) { my $cells = $table->[0]{rows}[$rank]{cells}; push @gene_score, { Rank => $rank, Ensembl_ID => Get_Label( $cells->[0]{data} ), RefSeq_ID => $cells->[1]{data}, Gene_Symbol => $cells->[2]{data}, Band => $cells->[3]{data}, Gene_Name => $cells->[4]{data}, Probability => $cells->[5]{data}, Known_Phenotype => $cells->[6]{data}, }; } sub Get_Label { my $link = shift; my $p = HTML::TokeParser::Simple->new( \$link ); while ( my $token = $p->get_token ) { next if ! $token->is_start_tag; return $token->return_attr( 'href' ) =~ /gene=(\w+)$/; } }
This can obviously be made less verbose, but I wanted it to be clear where the data was coming from.

Cheers - L~R

Added the $table->[0]{rows}[$rank]{cells} shortcut

In reply to Re: adding rank to a match in while loop. by Limbic~Region
in thread adding rank to a match in while loop. by BioGeek

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.