Thanks a lot for your suggestions, it helped me a lot!! :)
Aravind
On 06/16/2010 05:14 PM, Jim Gibson wrote:
At 4:30 PM +0200 6/16/10, Aravind Venkatesan wrote:
Hi everyone,
I have written a code that takes in two files (containing a set of
terms) as arguments
eg: testfile1
CCO:P0000056 cell cycle
CCO:U0000002 cell-cycle process
CCO:P0000308 cell cycle process
CCO:P0000004 regulation of progression through cell cycle
CCO:P0000005 cell cycle checkpoint
CCO:U0000000 cell-cycle entity
CCO:P0000294 regulation of cell cycle
reads the contents and gets an intersection (common terms) from the
two file. but the on implementation its throwing me the following
errors:
Use of uninitialized value $input_file1 in open at
get_intersection_terms_from.pl line 9.
readline() on closed filehandle FILEONE at
get_intersection_terms_from.pl line 11.
Use of uninitialized value $input_file2 in open at
get_intersection_terms_from.pl line 16.
readline() on closed filehandle FILETWO at
get_intersection_terms_from.pl line 18.
the code is given below:
#!/usr/local/bin/perl -w
use Carp;
use strict;
use warnings;
# Takes in first argument
my $input_file1 = $_;
Command-line arguments are placed in the @ARGV array, not the $_
variable. Thus, the above line should be:
my $input_file1 = shift @ARGV;
open (FILEONE, $input_file1);
You should always check whether the open succeeded, use local
variables for file handles, and use the 3-argument version of open for
best results:
open(my $fileone, '<', $input_file1) or die("Can;t open $input_file1:
$!);
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/