The two values you are returning are simply the names of those files, and not actually the contents. You are setting $out1 and $out2 as the name you want for the output files, then telling clustalw2 to use those names for the output files, but you're missing the step where you read those files into your program.

You can do something like the following before you return (note: untested code):

my ($result1, $result2); { local $/; open my $fh1, "<", $out1 or die "Could not open $out1: $!"; $result1 = <$fh1>; open my $fh2, "<", $out2 or die "Could not open $out2: $!"; $result2 = <$fh2>; } return ($result1, $result2);

As a side note, I'm a little confused by some of the things you are doing. Firstly, what is the point of if ($contig1 =~ m/contig1$/)? Don't you already know that $contig1 ends with "contig1", since you set it at the beginning of the sub? Secondly, you never use the $contig*_out variables. Did you mean to do something with them?


In reply to Re: Trouble getting the file contents from return values by lostjimmy
in thread Trouble getting the file contents from return values 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.