>>>>> "JD" == John Delacour <johndelac...@gmail.com> writes:

  JD> use strict;

use warnings ;

  JD> my $read = 0; my @genes; my %hash;

why the $read flag?

  JD> while (<DATA>){
  JD>   chomp;
  JD>   $read = 1 if /^GENES/;

you can always just so this and test for it. i don't know the data logic
so i can't go further. at least you can run this and assign it to $read
to remove redundancy. also you can declare $read here.

        my $read = s/^GENES//;

  JD>   $read = 0 unless /\s[A-Z]{3}:/;

since you don't do the work unless that passes, just next away:

        next if /\s[A-Z]{3}:/;

now you don't need to test $read at all. again, i haven't checked the
flow logic so i could be wrong. i just smell better logic here. having
data in this example (sure i can look at the OP's post but i am tired. :)

  JD>   if ($read){
  JD>     s/^GENES//;

that line isn't neded.

  JD>     s/^\s+//;
  JD>     push @genes, $_;
  JD>   }
  JD> }
  JD> for (@genes){
  JD>   my ($taxon_label, $gene_label) = split /:\s*/;
  JD>   $hash{$taxon_label} = $gene_label;
  JD> }

if the list isn't that long you can map/split in one cleaner line. and
don't use %hash for a hash name.

        my %labeled_genes = map { split /:\s*/ } @genes ;

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to