Sunday, May 12, 2013

Perl - Introduction

Ever wonder what's the starting point for learning any scripting for automating your environment? Well, this can be your place to start learning industry's one of the most powerful scripting tool 'perl'. Make sure you follow all the related posts and practice more.

-Perl fits in between the C/C++ programming languages and shell level utilities like awk, grep and sed.
-Perl beats shell programming languages in speed and beats C/C++ in ease of use.
-Perl is quite high level with “dense” and portable codes with the following attributes:
-Faster to write and read
-Faster to debug
-Easy to maintain.

Perl Popularity:
-Just like many popular tools, the creator of perl released it to the Usenet community.
-Users of the early perl gave feedback and made requests to the creator.
-Perl grew in features as well as popularity.
-Perl was initially on Unix systems, and it is now available on nearly all systems.

How to run a simple perl program?
-A perl program can be invoked by either execute it directly
-Or pass the source code to the perl interpreter.
-The first two characters in a shell program “#!” tells the computer what to use to execute the rest of the program.
-Perl is typically installed:
 /usr/bin/perl or /usr/local/bin/perl.
-If not, you need to find out and specify it in the first line of your perl code.

unix> cat
print "Hello World!\n";

unix> ls -l
-rw-r--r--  1 hippo users 4 May  8 2:52

unix> Permission denied.

unix> perl
Hello World!

unix> chmod +x
unix> ls -l
-rwxr-xr-x  1 sun users 4 May 12 2:52

Hello World!

Turn on warning:
-By default, perl does not warn you of suspicious coding.
-To run a perl program with warning on, use the one of the two forms:

% perl –w perl_prog

#!/usr/bin/perl –w
require 5.001;

-The second line indicates which version of perl the program expects.

-Some websites for you to browse:
-You can simply google for any questions you may have, and you have a good chance of getting your answers.

Please click here for Part-1

No comments:

Read more: