in reply to Re: Compare hash with arrays and print
in thread Compare hash with arrays and print

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!

Replies are listed 'Best First'.
Re^3: Compare hash with arrays and print
by toolic (Bishop) on Jul 12, 2010 at 19:26 UTC
    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.