Perl 你好世界不工作 [英] Perl Hello World Not Working

查看:56
本文介绍了Perl 你好世界不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习 perl.我编写了一个 Hello World 程序 - hello.pl 并使用+x"使其可执行.

I've just started learning perl. I wrote a Hello World program - hello.pl and made it executable using '+x'.

我可以使用 perl hello.pl 执行它,但是当我尝试 ./hello.pl 时,出现错误:错误:没有这样的文件Hello World"

I can execute it using perl hello.pl, but when I try ./hello.pl, an error is coming: Error: no such file "Hello World"

是什么原因?

我的程序

use warnings;
use strict;
use 5.010;

print "Hello World";

我的错误:

./hello.pl: line 1: use: command not found./hello.pl: line 2: use: command not found./hello.pl: line 3: use: command not found错误:没有这样的文件Hello World"

./hello.pl: line 1: use: command not found ./hello.pl: line 2: use: command not found ./hello.pl: line 3: use: command not found Error: no such file "Hello World"

推荐答案

使用 shebang line 在程序的顶部.它告诉内核或 Apache 将文件解释为 Perl 脚本.并且应该把use warnings;use strict; 放在程序的顶部

Use shebang line in the top of the program. It tells the kernel or Apache to interpret the file as a Perl script. and should put the use warnings; and use strict; in the top of the program

#!/usr/bin/perl
use warnings;
use strict;

print "hello world";

关于shebang的更多信息

And more about shebang

shebang 是否确定了 shell运行脚本?

为什么shebang行总是排在第一位线?

这篇关于Perl 你好世界不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆