in reply to Up for Critique
Now, instead of using an "array" of variables, use a hash. This simplifies things massively:my %acrhom_prefix = ( BAC => '(.*)\s*', LENGTH => '(.*)\s*', OSME => '(.*)\s*', CHR_START => '(.*)\s*', BAC_START => '(.*)\s*', BAC_END => '(.*)\s*', ORIENTATION => '(\w)\w*\s*', );
Now, I've just typed this into the editor here, so this is really just theory and not tested, but the idea is that this can be applied to a few other areas where you do the same thing.sub ParseAChroms { my ($achromref) = @_; my (%value); foreach (@$achromref) { my ($prefix, $data) = /^(\S+):\s+(.*)/; if (my $pattern = $achrom_prefix{$prefix}) { ($value{lc $prefix}) = $data =~ /^$pattern$/; } } return @data{qw[ type ac_id length chr_num chr_start chr_end bac_start bac_end orient]}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Up for Critique
by biograd (Friar) on Mar 23, 2002 at 06:43 UTC | |
by jeffa (Bishop) on Mar 23, 2002 at 17:31 UTC |