Perl语法错误

use*_*167 -3 perl

我试图找到语法错​​误,但我不能.

错误信息:

syntax error at /Users/MMM/Desktop/extract2.pl line 52, near "$dbm{"
syntax error at /Users/MMM/Desktop/extract2.pl line 57, near "}"
Execution of /Users/MMM/Desktop/extract2.pl aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)

代码:(错误行标记)

#!/usr/bin/Perl
#Extract the accession number and#!/usr /bin/perl
#Extract the accession number and the sequence section from the records in the GenBank file
#Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind

#use warnings;
use BeginPerlBioinfo;
use strict;

# Declare and initialize variables
my $fh;
my $record;
my $dna;
my $annotation;
my $fields;
my $dbm = ' ';
my $answer;
my $offset;
my $LSU = '/Users/MMM/Desktop/FUNGUS/LSU.gb';

# open DBM file, creating if neccessary
unless (dbmopen(my %dbm, 'GB' , 0644)) {
    print "Cannot open DBM file GB with mode 0644\n";
    exit;
}

#Parse GenBank library, saving accession number and sequence in DBM file

$fh = open_file($LSU);

$offset = tell ($fh);

while ( $record = get_next_record($fh))   {
    #Get accession field for this record.

    ($annotation, $dna) = get_annotation_and_dna($record);

    my %fields = parse_annotation( $annotation);

    my $accession =  $fields { 'ACCESSION'};

    # extract just the accession number and sequence from the accession field
    #-- remove any trailing spaces
    $accession =~ s/^ACCESSION\s*//;

    $accession =~ s/\s*$//;

    #store the key value of accession/offset

    my $dbm{$accession} = $offset; # <--- ERROR

    #get offset for the next record

    $offset = tell($fh);
}
Run Code Online (Sandbox Code Playgroud)

jwo*_*der 6

my $dbm{$accession}是无效的语法; my只能与变量一起使用,而不能与散列或数组下标一起使用.甚至没有必要使用my下标; 只是写$dbm{$accession} = $offset;.