Table of Contents

~~TOC~~

Lab46 Tutorials

Perl

Programing Language

created in 1987 as a UNIX scripting language Perl has influences from c/c++, sed and unix shell scripting. It is now a full featured high-level programing language that makes text manipulation simple. Perl is also used in dynamic web page creation and report generation. understanding of UNIX shell commands and regular expressions are essential to take full advantage of the Perl language.

First Program

    #!/usr/bin/perl
 
    print "hello world!";

save as hello.pl

run

perl hello.pl

Common Commands

Data Types
Input, Output, Comments
Arithmetic Operators
Logical Operators
If Structure
if ($var > 0)
    {
    print "something";
    }
else
    {
    print "something else";
    }
For Loop
for ($var = 0; $var < 10; $var++)
    {
    print "this is a loop";
    }

Input output program

#!/usr/bin/perl
 
my $name;
my $num;
 
print "What is your name: ";
$name = <STDIN>;
chomp($name);
for ($num = 0; < 10; $num++)
    {
        print $num." ";
        print "Hello, $name\n";
    }