运行perl脚本出现require: command not found
(2011-08-22 18:47:01)
标签:
perlcommandnotfound教育 |
使用./rdseed.pl运行perl脚本时出现了一堆如下所示错误:
-------------------------------
./rdseed.pl: line 6: require: command not found
./rdseed.pl: line 7: require: command not found
./rdseed.pl: line 8: require: command not found
./rdseed.pl: line 10: @ARGV==2: command not found
./rdseed.pl: line 10: die: command not found
./rdseed.pl: line 11: =: command not found
./rdseed.pl: line 16: syntax error near unexpected token `{'
./rdseed.pl: line 16: `if($ARGV[1] =~ /\d+/){'
--------------------------------
perl脚本的源码的前几句如下所示:
-------------------------------
# The program was revised from the past programs by Yu Chen in Jun 2010 *
# The subroutines were written in seed1 to seed3.pm. *
#!/usr/bin/perl -w
require "./seed1.pm";
require "./seed2.pm";
require "./seed3.pm";
@ARGV==2 || die "Usage:perl $0 seed_file header (200805120628)\n";
$seedfile = $ARGV[0];
--------------------------------
上网查到某人给出的回答是:
-------------------------------
./rdseed.pl: line 6: require: command not found
./rdseed.pl: line 7: require: command not found
./rdseed.pl: line 8: require: command not found
./rdseed.pl: line 10: @ARGV==2: command not found
./rdseed.pl: line 10: die: command not found
./rdseed.pl: line 11: =: command not found
./rdseed.pl: line 16: syntax error near unexpected token `{'
./rdseed.pl: line 16: `if($ARGV[1] =~ /\d+/){'
--------------------------------
perl脚本的源码的前几句如下所示:
-------------------------------
# The program was revised from the past programs by Yu Chen in Jun 2010 *
# The subroutines were written in seed1 to seed3.pm. *
#!/usr/bin/perl -w
require "./seed1.pm";
require "./seed2.pm";
require "./seed3.pm";
@ARGV==2 || die "Usage:perl $0 seed_file header (200805120628)\n";
$seedfile = $ARGV[0];
--------------------------------
上网查到某人给出的回答是:
My guess is that you're using a weird flavour of unix that
doesn't respect the #! line, and is trying to
run the script via the
shell instead of via perl.
Another reason why this might happen is if tt.pl
starts with a blank
line. The
#! must appear at the very start of the
file.
Try running perl tt.pl and see what happens.
根据上面的回答,运行perl rdseed.pl,脚本得以正常运行,即根本原因在于perl脚本要求第一行是#!
perl程序员都是懒的,perl
rdseed.pl显然没有./rdseed.pl省事,所以记得将#!放在第一行,注释放在#!的后面几行~
前一篇:如何去除linux下的滴滴声
后一篇:perl调试命令

加载中…