Perl Syntax

In this post are mentioning the all bases syntax which are commonly used in perl programming. such how to inputs,how to display message on console screen print ,how to use of comments so on.

Creating and running perl program

Perl is a scripting language. We can write perl source code in any text editor and save this file with the (.pl) extension. Source code file can be contain single or multiple perl statement which are execute using this command.


Here code is a name of source code file. Generally perl source code file are contains this three line of code at the top.

use warnings;
use strict;

The #! is commonly called a "shebang" and it tells the computer how to run a script. And /usr/bin/perl is Perl interpreter location. use strict; statement are catch all potential errors in program.


Comment are used in perl programming to describe the code explanation and short notes instruction. All lines which is commented this are not execute in run time. There are two types of comment can be used in perl source code. single line comment and multi line comments.

Single line comment : This comment are used to describe small overview of programmer thinking in a few words. That are start with # sign.

#single line comment

Multiline Comment : This comment can be describing long explanation in form of multiline text. That is start with =begin and end with =cut. And inside this all text is form of and comment.

multiline text 

Input and output

print is an operator in perl programming, which are used to display message into console screen. Each statement in perl programming are terminate by using of a semicolon.

print "\nHello World!";
Hello World!
use strict;
use warnings;
print "Enter your name : ";

my $name = <STDIN>;
chomp $name;
print "Hello, $name\n";
Enter your name : Smith
Hello, Smith

Perl Command Line arguments

Command line argument are used in special purpose, Generally using command line value are set up initial setting on you'll Apps. @ARGV are store that parameter values into in form of an arrays. Which are retrieved by index values.

use strict;
use warnings;

#display Command Line arguments
print $ARGV[0],"\n";
print $ARGV[1],"\n";
print $ARGV[2],"\n";
print $ARGV[3],"\n";
perl testing one two three


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment

© 2021,, All rights reserved