in reply to Compare hash with arrays and print

Can you clarify what problem you are having?

If the problem is that your 3 output files are empty, then you need to print something to them. The only print I see in your code has been commented out.

Replies are listed 'Best First'.
Re^2: Compare hash with arrays and print
by ad23 (Acolyte) on Jul 12, 2010 at 19:01 UTC

    Doesn't select command selects the file and print the contents?

    I used it as below in my code before:

    my $in = $ARGV[0]; my $x = $ARGV[1]; my $y = $ARGV[2]; open IN , "<$in" or die $!; open X, ">$x" or die $!; open Y, ">$y" or die $!; while (<IN>) { if (/^>/) { if (/infor_present:/) { select X; } else{ select Y; } } print; }

    In the above code, there is a "print" statement after it comes out of loop. So in order to print the contents in multiple files, how can we use print in this manner?

    Also, I tried making a hash for the Sample.fa files with header as key and seq as values. But since I am reading multiple files, that approach is not working (as I run out of memory!). Kindly help.

    Thanks!

      Doesn't select command selects the file and print the contents?
      No, select alone will not print to a file. You must also use print, as you have done in your new code example.