< Perl Tutorial

Perl hello world

← Previous Next →

Hello World Program

Any programming language tutorial has to start with showing the “Hello, world” program. So, here it is in Perl:

print "Hello, world!\n";

Normally Perl treats a line starting with # as a comment and ignores it. However, the # and ! characters together at the start of the first line tell it how the file should be run. In this case the file should be passed to the perl interpreter, which lives in /usr/bin/perl.

The print function tells perl to display the given text without the quotation marks. The text inside the quotes is not interpreted as code and is called a string. Here "\n" simply means a newline.

Now, click on Run in the IDE and it will open a prompt window showing the result of the above code:

Hello, World!

So, this was our first Perl code.

← Previous Next →