Introduction to Perl

Introduction to Perl

Perl is a interpreted language. It is almost available in all popular operating systems today. Perl will be similar to C language and awk.

Basics

  • Perl script file mostly will have the extension .pl
  • In unix and Linux flavours, the perl file should have an execution permission.
  • Start the perl script file with #!/usr/bin/perl
  • Dont forget to terminate perl commands with ; (semicolen). eg., print “Hello worldn”;

Program 1

Always the first program I try on any language is hello world, so perl’s hello world program is here for Linux and UNIX flavors,

#!/usr/bin/perl

print “Hello world.n”;

In Windows the same program will look like,

#!D:/perl/perl.exe

print “Hello world.n”;

  • The first line (in both examples) is a comment for perl, but for shell it tells which interpriter in what path to use on the file.
  • The second command print is similar to printf in C language with some difference. Let’s learn the difference later.

Syntax to run Perl programs

perl <program name> <arguments>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s