我有代码将当前目录中文件的所有文件句柄存储为哈希值。键是文件的名称。
my %files_list; #this is a global variable.
sub create_hash() {
opendir my $dir, "." or die "Cannot open directory: $!";
my @files = readdir $dir;
foreach (@files) {
if (/.text/) {
open(PLOT, ">>$_") || die("This file will not open!");
$files_list{$_} = *PLOT;
}
}
}
在我面临一些编译问题的代码中,我正在使用打印语句。
my $domain = $_;
opendir my $dir, "." or die "Cannot open directory: $!";
my @files = readdir $dir;
foreach (@files) {
if (/.text/ && /$subnetwork2/) {
print $files_list{$_} "$domain"; #this is line 72 where there is error.
}
}
closedir $dir;
编译错误如下:
String found where operator expected at process.pl line 72, near "} "$domain""
(Missing operator before "$domain"?)
syntax error at process.pl line 72, near "} "$domain""
谁能帮我理解错误?