Here is process_article:

sub process_article { my $fh=shift; # Filehandle my $locations=shift; # Reference to hash containing location informati +on for this article my $keywords=shift; # Reference to an array containing keywords my $all=shift; # Reference to a list of all keywords or chromosomal ba +nds found if (-e "$$locations{file}") { # If file exists in the location indicat +ed by the index file open(INFO, "$$locations{file}") or die("cannot open file $$locatio +ns{file}: $!"); } else { # If not, search for it my ($file)=($$locations{file}=~/.+\/(.+)/); # Get just the filenam +e find(sub{m/$file/ and $file=$File::Find::name}, 'c:/perl' ); open(INFO, "$file") or die("cannot open file $file: $!"); } seek (INFO, $$locations{offset}, 0); # Set location to article my $string=<INFO>; # Get line from file my ($title, $line, $abstract)=($string=~/(.+?)\t(.+)\t(.*)/); if (@$keywords) { # If keywords were provided my ($score, @found)=find_keywords($title.' '.$abstract, @$keywords +); # Get keywords push @$all, @found; my $kwords_found=join('|', @found); print $fh "$title\t$line\t$kwords_found\t$score\n" if ($score>0); +# Print line } else { # No keywords provided, means look for chromosomal bands my ($score, @found)=find_bands($title.' '.$abstract); # Get chromo +somes push @$all, @found; my $chroms_found=join('|', @found); print $fh "$title\t$line\t$chroms_found\t$score\n" if ($score>0); +# Print line } close(INFO); }

-----------------------------------

Any comments about coding style are welcome.

In reply to Re: Re: Problem with a hash of hashes by dannoura
in thread Problem with a hash of hashes by dannoura

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.