0

我想在 perl 中重新加载一个预索引文件,该文件之前已被索引如下:

./first_script.pl hg19.fa

use Bio::DB::Fasta;

my $db = Bio::DB::Fasta->new($file_fasta);

...

在另一个脚本中,我想重新加载现有的索引文件。

./script.pl hg19.fa.index 输入

#!/usr/bin/perl

use warnings;
use strict;

use Bio::DB::Fasta;

my $fasta_index_file = $ARGV[0];
my $input_file = $ARGV[1];

open(FH,"<$input_file");

my $db->index_file($fasta_index_file);

在描述中它是 syas

 Title   : index_file
Usage   : $db->index_file($filename)
Function: (re)loads a sequence file and indexes sequences offsets in the file
Returns : seq offsets in the file
Args    : filename,
           boolean to force reloading a file

但它返回以下错误:

Can't call method "index_file" on an undefined value at script.pl line

如果我再次使用,在第二个脚本中:

my $db = Bio::DB::Fasta->new($file_fasta);

它立即进入下一步!这是否意味着它已经意识到它的存在?

4

1 回答 1

1

您没有$db在第二个脚本中定义任何地方。

通常情况下,use strict;会揭示这一点,并且应该是您进行故障排除的第一步。

于 2015-04-10T12:13:51.197 回答