These look very similar, the similarity is just obscured by some comments. So let's remove the comments, and find out what's the difference:
diff -u a b --- a 2009-05-05 19:55:21.000000000 +0200 +++ b 2009-05-05 19:54:44.000000000 +0200 @@ -1,7 +1,7 @@ -sub blast_parse{ +sub blast_hd_parse{ my($maid,$maid_dir) = @_; - my $url_hu = "http://hu_seq/"; - my $hu = get($url_hu.$maid); + my $url_hd = "http://hd_seq/"; + my $hd = get($url_hd.$maid); my $ltvec_small = $maid_dir.$maid."Ltvec_small.fa"; open ($hu); my $seq=<$in>; @@ -9,7 +9,8 @@ open ($hu, ">".$maid.".fa"); print $hu_fa ">$maid\n$seq"; close($hu_fa); - my $command = "bl2seq -p blastn -i $ltvec_small -j $hu_fa -F F -D + 1"; + + my $command = "bl2seq -p blastn -i $ltvec_small -j $hd_fa -F F -D + 1"; print $command,"\n"; open OUTPUT, '>', "$maid_dir\\".$maid."_bl2seq.out" ; STDOUT->fdopen( \*OUTPUT, 'w');

(A graphical diff utility like gvimdiff is also very helpful).

The first difference is the sub name, which we'll ignore for now. The second difference is a differently named variable, and a different constant value. Let's just name the variables $url in both subs, and assume that $hd is actually a typo (it's not used anywhere below in the code).

Then you can clean up your code a bit (do you use strict;? you know you should!) and you'll find that the subs are identical, except for the different URL, which can be provided as another parameter.


In reply to Re: how can I combine into one method by moritz
in thread how can I combine into one method by lomSpace

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.