Hi,

I'm trying to create a genbank library file that contains several genbank
records. I read in the genbank record names from a separate file into an
array and then loop through array of file names, open each file and read
contents into another array. The problem is in looping through the array and
opening individual files. The code is below. I successfully populate @ids
but cannot manage to loop through @ids, open files and populate @library as
I get "can't open file !\n"; messages. Please advise at your convenience,
Many thanks,

galeb

#!/usr/bin/perl
# create_gb_library.pl
use strict; use warnings;

open IDFILE, shift or die "can't read idfile!\n";

my @ids = '';

while( <IDFILE> ) {
    my $filename = $_;
    push( @ids, $filename );
}

my @library;

for my $id( @ids ) {
    chomp $id;
    open FILE, $id or die "can't open file $id!\n";
    $/ = "//\n";    # input-record separator is genbank end-of-record
separator
    my $record = <FILE>;
    push( @library, $record)
}
close FILE;

open OUTLIBRARY, ">gblibrary.txt" or die "can't open gblibrary.txt!\n";

print OUTLIBRARY @library, "\n";

close OUTLIBRARY;

Reply via email to