Hi Experts --
I've been looking at this too long -- I can't spot the (probably obvious) problem. I'm hoping a fresh set of eyes will help.
Here is a stripped down version of a larger script. The actual script has many more entries in the %species hash, does some stuff between the "foreach" loops, actually does some work on the downloaded files, etc., but this is sufficient to trigger the error:
"Modification of a read-only value attempted at C:\Documents and Settings\Mike\Desktop\bf gene data\test.pl line 31."
The FTP portion retrieves the files fine -- in fact, once I have them, I can comment out that entire piece and the error still occurs.
Note that the script does not die at opening the file (line 30), and that the "for" loop and construction of the $file name variable is the same for both the FTP and the "open file" sections, but the script only dies when it attempts to read the file; the FTP portion works as expected.
I've tried all the obvious stuff: the files are not read-only, are in fact there, and can be opened and read if named explictly.
#!/usr/bin/perl -w
use strict;
use Net::FTP;
use Cwd 'abs_path';
my %species = (
'Bacteroides_fragilis_NCTC
_9434' => 'CR626927',
);
my $home = abs_path(".");
my $datapath = "$home/srRNA";
mkdir $datapath unless (-e $datapath);
chdir ($datapath) or die;
foreach my $organism (sort keys %species) {
my $ftp = Net::FTP->new("
ftp.ncbi.nih.gov", Debug => 0) or die "Cannot connect to
ftp.ncbi.nih.gov: $@";
$ftp->login("anonymous",'-
anonymous@
') or die "Cannot login ", $ftp->message;
$ftp->cwd("/genbank/genome
s/Bacteria
/$organism
/") or die "Cannot change working directory ", $ftp->message;
for ('.ptt', '.rnt') {
my $file = $species{$organism} . $_;
$ftp->get($file) or die "get $file failed ", $ftp->message;
}
$ftp->quit;
}
foreach my $organism (sort keys %species) {
for ('.ptt', '.rnt') {
my $file = $species{$organism} . $_;
open (TAB, $file) or die "Can't open $file: $!\n";
while (<TAB>) {
next unless /^\d+\.\.\d+/;
}
close (TAB);
}
}
Thanks for your help...
Start Free Trial