我从下面的脚本调用路径时遇到错误,上面显示错误。
./ heartbeat.pl:my:not found ./heartbeat.pl: $ /:不是标识符
my $ini_file = 'Search.ini';
local $/ = undef;
open( FH, $ini_file );
my $data = <FH>;
close(FH);
( my $search_item ) = $data =~ /<String_search>(.*?)<\/String_search>/;
( my $search_file ) = $data =~ /<File_search>(.*?)<\/File_search>/;
my $dir = $ARGV[0];
#my $dir = '/apps/scope/mst/scripts/heartbeat';
opendir( DIR, $dir );
my @files = grep {/($search_file)/} readdir(DIR);
closedir(DIR);
foreach (@files) {
open( IN, "$dir\\$_" ) || die "$_ $!";
my $file_data = <IN>;
#print $file_data;
print "FOUND:- $dir\\$_" if ( $file_data =~ /($search_item)/g );
close(IN);
}
答案 0 :(得分:1)
使用perl ./heartbeat.pl
调用您的脚本,或在脚本的第一行添加#!<path_to_perl>/perl
如果您不这样做,系统会将您的程序称为shell命令