Pages

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.



Overview:
========
-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.

Snippet:
----------
unix>
unix> cat hello.pl
#!/usr/bin/perl
print "Hello World!\n";

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

unix> hello.pl
hello.pl: Permission denied.

unix> perl hello.pl
Hello World!

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

unix> hello.pl
Hello World!
unix>

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.

Help:
====
-Some websites for you to browse:
http://www.cpan.org
http://www.perl.com
-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: http://bloggerknown.blogspot.com/2013/02/changing-blog-page-by-page-number.html#ixzz2TaVMS7IW