Here's just something that came to mind. Instead of using your massive if structure in
ParseAChroms, you could try doing something a lot simpler, such as declaring
what you're looking for in a sort of table:
my %acrhom_prefix = (
BAC => '(.*)\s*',
LENGTH => '(.*)\s*',
OSME => '(.*)\s*',
CHR_START => '(.*)\s*',
BAC_START => '(.*)\s*',
BAC_END => '(.*)\s*',
ORIENTATION => '(\w)\w*\s*',
);
Now, instead of using an "array" of variables, use a hash. This simplifies things massively:
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]};
}
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.
Further, instead of passing arguments back and forth in a particular
fixed order, why not return a HASH-ref? This makes it easy to add new data to the return value without breaking other functions which use it.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.