Professional Documents
Culture Documents
Csc410 Perl Programming
Csc410 Perl Programming
Csc410 Perl Programming
PROGRAMMING
CSC 410:E-TECH & GATEWAY PROGRAMMING
WHAT IS PERL
• Perl is a high-level, general-purpose programming language that
was originally developed for text manipulation and extraction of
information from text files. The name "Perl" originally stood for
"Practical Extraction and Reporting Language." Over time, Perl has
evolved into a versatile scripting language used for various
purposes, including system administration and web development
• A scripting language is a type of programming language that is
interpreted rather than compiled
• scripting languages are executed directly by an interpreter. This
means that the source code is read and executed line by line at
runtime.
FEATURES OF PERL
• Perl is a stable, cross platform programming language
• Perl is an Open Source software, licensed under its Artistic
License, or the GNU General Public License (GPL).
• Perl is an interpreted language, meaning that it is not compiled
into machine code but is executed directly by an interpreter.
• Perl is widely used for system administration tasks and scripting on
Unix and Linux systems.
• Perl has an active community, and the Comprehensive Perl Archive
Network (CPAN) is a vast repository of Perl modules and libraries
that can be easily integrated into Perl programs.
Visit the URL https://brew.sh/ for installation guide on
how to install the Perl Interpreter that is designed to ru
on macOS or Linus
Setting Up Perl Development Environment
This line is called a shebang line, and it indicates the path to the Perl
interpreter. It tells the system that this script should be executed using
Perl.
The Second & Third lines of the every Perl program must begin with:
These statements are called
pragmas or directives to the
Perl Interpreter
PERL SYNTAX OVERVIEW
The use strict statement is called pragma and it forces you to code properly
to make your program less error-prone. For example: It forces you to
declare variables before you use them. You can declare variable using “my”
keyword. “my” keyword restricts the scope of the variable to local
Example
PERL SYNTAX OVERVIEW
• use warnings pragma helps you find typing mistakes, it warns you
whenever it sees something wrong with your program. It would
help you find mistakes in your program faster
Note: The most important point to note here is that “use strict” would
abort the execution of program if it finds errors. On the other hand “use
warnings” would only provide you the warnings, it wont abort the
execution. You should always use these two pragmas in your programs as
it is a good programming practice.
PERL SYNTAX OVERVIEW
• Floating-Point Numbers:
NUMERIC LITERALS
• Numeric Operators
Math Functions
PERL INTEGERS
• Remember when the integer number is big, you often use a comma
as a separator to make it easier to read e.g., 123,763,213.
• However, Perl already uses a comma (,) as a separator in the list so
for integer numbers Perl uses an underscore character
• instead. In this case, 123,763,213 is written in Perl as 123_763_213
• Perl also supports other formats including binary, octal, and
hexadecimal.
• The following table shows you prefixes for formatting with binary,
octal, and hexadecimal integers.
PERL INTEGERS
Classwork