This tutorial explains how to write a simple hello world program in Perl Scripting language.

Hello World is the first program written by developers to learn any new programming language.

It is easy and quick to code a language in Perl.

This post covers

  • Writing a simple hello world program in Perl
  • Print the Hello World to console
  • Compile and execute a program using the command line.

Perl Hello World Example program

To write a Hello World program, please follow the below steps

  • Open any text editor
  • Create a file called HelloWorld.pl, where ml is an extension for OCaml code.
  • Add the below lines of code
# HelloWorld.pl Hello World application
print "Hello World application" 
= Hello world sample program
 Basic program to print hello world to console
 First code to write in Perl programming language 
 =cut

    print "Hello World app" ;

Comments are single-line or block/multi-line comments and are ignored by the Python interpreter.

Single lines are started with #, followed by single-line text, and end with a line. Multi-line comments span in multiple lines, starting with = and ending with =cut and each line contains a comment string

The print function prints the string to standard output such as console

There is no main function in Perl.

How to compile and execute the program in Perl

Perl language has an interpreter(perl). Once you installed the Perl language, the Perl command is available on the command line

Below command used to execute a Perl code

$perl HelloWorld.pl

It prints the string to the console.