Dear Programmers,
Please help me debug the following perl script. Thanks in advance!
I keep getting the same error msg "readline() on closed filehandle file1 at drug_list_formidterm.pl line 12."
#!usr/local/bin/perl -w
use strict;
my @table;
my $drug;
my $category;
my $line;
open (file1, $ARGV[0]);
open (file2, ">tab_delimited.txt");
while (<file1>){
if ($_=~/^(.+)\t(.+)$/){
$drug=$1;
$category=$2;
$line=$drug."\t".$category;
}
push (@table, $line);
}
foreach my $seq(@table){
print file2 "$seq.\n";
}
close (file1);
close (file2);
Regards,
novice for perl
Please help me debug the following perl script. Thanks in advance!
I keep getting the same error msg "readline() on closed filehandle file1 at drug_list_formidterm.pl line 12."
#!usr/local/bin/perl -w
use strict;
my @table;
my $drug;
my $category;
my $line;
open (file1, $ARGV[0]);
open (file2, ">tab_delimited.txt");
while (<file1>){
if ($_=~/^(.+)\t(.+)$/){
$drug=$1;
$category=$2;
$line=$drug."\t".$category;
}
push (@table, $line);
}
foreach my $seq(@table){
print file2 "$seq.\n";
}
close (file1);
close (file2);
Regards,
novice for perl