in reply to Re: Problem with a hash of hashes
in thread Problem with a hash of hashes
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Problem with a hash of hashes
by graff (Chancellor) on Aug 08, 2003 at 04:15 UTC | |
by dannoura (Pilgrim) on Aug 08, 2003 at 05:00 UTC |