Sei sulla pagina 1di 4

PERL is a family of high-level, general-purpose,

interpreted, dynamic programming languages.


PERL is short for "Practical Extraction and Report
Language". Perl was originally developed by Larry
Wall in 1987 as a general-purpose Unix scripting
language to make report processing easier. Perl is
a programming language developed especially
designed for text processing. It stands for Practical
Extraction and Report Language. It runs on a
variety of platforms, such as Windows, Mac OS, and the various versions
of UNIX.
Since then, it has undergone many changes and revisions. The Perl
languages borrow features from other programming languages including
C, shell scripting (sh), AWK, and sed. They provide powerful text
processing facilities without the arbitrary data-length limits of many
contemporary Unix command line tools, facilitating easy manipulation of
text files. Perl 5 gained widespread popularity in the late 1990s as a CGI
scripting language, in part due to its string parsing abilities.
According to Wall, Perl has two slogans. The first is "There's more
than one way to do it", commonly known as TMTOWTDI. The second
slogan is "Easy things should be easy and hard things should be possible".
FEATURES:
The overall structure of Perl derives broadly from C. Perl is
procedural in nature, with variables, expressions, assignment statements,
brace-delimited blocks, control structures, and subroutines.
Perl also takes features from shell programming. All variables are
marked with leading sigils, which allow variables to be interpolated
directly into strings. However, unlike the shell, Perl uses sigils on all
accesses to variables, and unlike most other programming languages
which use sigils, the sigil doesn't denote the type of the variable but the
type of the expression. So for example, to access a list of values in a hash,
the sigil for an array ("@") is used, not the sigil for a hash ("%"). Perl also
has many built-in functions that provide tools often used in shell
programming (although many of these tools are implemented by
programs external to the shell) such as sorting, and calling on operating
system facilities.
Perl takes lists from Lisp, hashes ("associative arrays") from AWK,
and regular expressions from sed. These simplify and facilitate many
parsing, text-handling, and data-management tasks. Also shared with Lisp
are the implicit return of the last value in a block, and the fact that all

statements have a value, and thus are also expressions and can be used
in larger expressions themselves.
Perl 5 added features that support complex data structures, firstclass functions (that is, closures as values), and an object-oriented
programming model. These include references, packages, class-based
method dispatch, and lexically scoped variables, along with compiler
directives (for example, the strict pragma). A major additional feature
introduced with Perl 5 was the ability to package code as reusable
modules. Wall later stated that "The whole intent of Perl 5's module
system was to encourage the growth of Perl culture rather than the Perl
core."
All versions of Perl do automatic data-typing and automatic memory
management. The interpreter knows the type and storage requirements of
every data object in the program; it allocates and frees storage for them
as necessary using reference counting (so it cannot de-allocate circular
data structures without manual intervention). Legal type conversions
for example, conversions from number to string are done automatically
at run time; illegal type conversions are fatal errors.

The most up-to-date and current source code, binaries, documentation,


news, etc. is available at the official website of Perl: http://www.perl.org/
Perl documentation is available in : http://perldoc.perl.org
Windows versions are available in
http://strawberryperl.com/
http://www.activestate.com/activeperl/downloads
To find out the version of PERL in Command prompt type the following &
press enter.

perl -v
This will display the information of installed PERL version.
COMMENTS:
Text starting from a "#" character until the end of the line is a
comment, and is ignored.

DATA TYPES:
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 is loosely typed language and there is no need to specify a type
for your data while using in your program. The Perl interpreter will choose
the type based on the context of the data itself.
Perl has three basic data types: scalars, arrays and hashes.

SCALAR:
A scalar is the simplest kind of data that Perl manipulates. They are
preceded by a dollar sign ($). A scalar is either a number, a string, or a
reference. A reference is actually an address of a variable which we will
see in upcoming chapters.
A scalar value can be acted upon with operators (like plus or
concatenate), generally yielding a scalar result. A scalar value can be
stored into a scalar variable. Scalars can be read from files and devices
and written out as well.
A number can be an integer number or a float. All are stored as C
double precision float numbers internally. A number can be specified as
decimal, octal, hexadecimal. All numbers are accessible as strings also. By
default, all the numbers are stored and processed as DECIMAL only. To
print in Hexa, Octal, Binary, scientific PRINTF() has to be used.
12
: integer
-2348
: integer ve
3.1412
-23.5e-4

: float number
: float number ve

017
-017

: octal number
: octal number -ve

0x8AE
-0x12F

: hexadecimal number
: hexadecimal number ve

0b011011
-0b011011

: binary number
: binary number ve

Printing Formated Numbers:


printf("\n\n Hexa: %x",0x10);

printf("\n\n
printf("\n\n
printf("\n\n
printf("\n\n
printf("\n\n
printf("\n\n
printf("\n\n

Binary: %b",0b101);
Octal: %o",017);
Scientific1: %f",1.6201e-4);
Scientific1: %g",1.6201e-4);
Scientific3: %.3g",1.6201e-4);
Scientific4: %e",1.6201e-4);
Scientific5: %.3e",1.6201e-4);

Potrebbero piacerti anche