Friday, December 25, 2009

Perl man

One of the best ways to learn programming tools and languages which fall under *nix domain is using "MAN PAGES".
The following is a list of key words to explore using the "perldoc" command in your shell.

Usually you can enter keywords for most of the perl related manual pages followed by "perldoc".
For eg. if you enter as in below:

################################

blah-blah$perldoc perlsyn

################################

it will output a buffer of text about perl syntax as in below:

################################

PERLSYN(1) User Contributed Perl Documentation PERLSYN(1)



NAME
perlsyn − Perl syntax

DESCRIPTION
A Perl program consists of a sequence of declarations and statements
which run from the top to the bottom. Loops, subroutines and other
control structures allow you to jump around within the code.

Perl is a free‐form language, you can format and indent it however you
like. Whitespace mostly serves to separate tokens, unlike languages
like Python where it is an important part of the syntax.

Many of Perl’s syntactic elements are optional. Rather than requiring
you to put parentheses around every function call and declare every
variable, you can often leave such explicit elements off and Perl will
figure out what you meant. This is known as Do What I Mean,
abbreviated DWIM. It allows programmers to be lazy and to code in a
style with which they are comfortable.

Perl borrows syntax and concepts from many languages: awk, sed, C,
Bourne Shell, Smalltalk, Lisp and even English. Other languages have
borrowed syntax from Perl, particularly its regular expression
extensions. So if you have programmed in another language you will see
familiar pieces in Perl. They often work the same, but see perltrap
for information about how they differ.

Declarations

The only things you need to declare in Perl are report formats and
subroutines (and sometimes not even subroutines). A variable holds the
undefined value ("undef") until it has been assigned a defined value,
which is anything other than "undef". When used as a number, "undef"
is treated as 0; when used as a string, it is treated as the empty
string, ""; and when used as a reference that isn’t being assigned to,
it is treated as an error. If you enable warnings, you’ll be notified...

################################

just like perlsyn below are other important keywords which you can use to put yourself on fast track of
learning and using perl...

perlpod -perlpod − the Plain Old Documentation format

perlpodspec − Plain Old Documentation: format specification and notes

perldata − Perl data types

perlop − Perl operators and precedence

perlunicode − Unicode support in Perl

perluniintro − Perl Unicode introduction

perlref − Perl references and nested data structures

perlfunc − Perl builtin functions

perlsub − Perl subroutines

perlmod − Perl modules (packages and symbol tables)

As you can see above, many of the keywords for pulling the man pages are intuitive. It can be hard to memorize all of the keywords(i don't know if they are termed as keyword, I learnt perl on my own:) )
So doing a little guesswork to spell the keyword can be a faster way to quickly pull up related man pages when you need to get some info on a perl construct that you intend to use in your program.

For eg. if you want to get to manual pages which has examples on "opening" things in perl then you could do construct a key word like this: perl open tut (for perl opne tutorial) and could enter with perldoc as in:

####################

blah-blah$ perldoc perlopentut

####################

Another example can be: perl object or perl obj as in perlobject or perlobj.
Trying each of your guessworks as in above will cater to a faster learning process, talking from my personal experience, I can say, I am sure :)


perlmodlib − constructing new Perl modules and finding existing ones

Few good example of using acronyms in your guess work is "perlboot" (boot=beginner's object oriented tutorial)

perlboot − Beginner’s Object−Oriented Tutorial

perltoot − Tom’s object−oriented tutorial for perl

perltooc − Tom’s OO Tutorial for Class Data in Perl


Some of my favorite keywords for getting info on perl regular expression:

perlre − Perl regular expressions

perlretut − Perl regular expressions tutorial

perlrequick − Perl regular expressions quick start


Some more keywords:

perlpacktut − tutorial on "pack" and "unpack"

PerlIO − On demand loader for PerlIO layers and root of PerlIO::* name
space

perlform − Perl formats

perltie − how to hide an object class in a simple variable

perlipc − Perl interprocess communication (signals, fifos, pipes, safe
subprocesses, sockets, and semaphores)

perlvar − Perl predefined variables

perlthrtut − tutorial on threads in Perl

perlcc − generate executables from Perl programs

perlcompile − Introduction to the Perl Compiler−Translator

perldebug − Perl debugging

perldebtut − Perl debugging tutorial

I will be composing more and more stuff on perl in future.
Thanks for reading from my page.

~nirmal