運行時,我有一個Perl腳本Info.perl
它開始像這樣Perl的「使用:命令未找到」從bash腳本
#!/usr/bin/perl
#!/usr/bin/bash
use List::Util qw(min max);
use List::MoreUtils qw{ all any };
use Cwd;
use Data::Dumper qw(Dumper);
use Env qw(INFODIR CONFDIR PROCDIR);
當我從終端運行它,它給了沒有問題,按預期工作。
但後來我有一個bash腳本run.sh
,只有在它
./Info.pl
當我運行該腳本,我得到以下錯誤
./Info.pl: line 4: syntax error near unexpected token `('
./Info.pl: line 4: `use List::Util qw(min max);'
如果我省略第4行我得到的以下消息:
./Info.pl: line 5: use: command not found
./Info.pl: line 6: use: command not found
./Info.pl: line 7: syntax error near unexpected token `('
./Info.pl: line 7: `use Data::Dumper qw(Dumper);'
是否有任何特殊的方式需要運行Perl scr ipt裏面的bash腳本?或者使用use
命令的特殊方式?
你實際上在你的perl腳本中有2個shebang行嗎? –
聽起來像你的文件正在作爲bash腳本執行,而不是Perl腳本。 – Wormbo
你如何從終端上運行它? Info.pl文件集是可執行文件嗎? –