Home | Add to Favorites | Ebooks Directory | News  
Perl  Script Programming
Home
PERL  Article
PERL Tutorial 
Perl Source Code
Perl Books
PERL Manual
Perl Download
PERL Tutorial

PERL Tutorial Continued



 

Example 1

To print a string the print command is used as follows The comments are given using # as prefix for a line
#print hello world
$str="hello world";
print $str;


Example 2

Initializing arrays and displaying them.

The @ symbol is prefixed to an array variable
To find the number of elements of an array, the scalar() method  taking the array variable  as an argument is used.
The scalar() method is an arithmetic operator. Dot (.) is the concatenation operator.
 

#intialization of array
@array1=("hello","world","common","let","us","go");
$count=scalar(@array1);
print @array1;
print "\n".$count;

Example 3

Reading input from the keyboard (Standard input)

To read the input from the standard input i.e., Keyboard, the <> diamond (readline) operator is used.The following program takes the input from the keyboard and displays it to the standard output i.e., monitor.

#standard input
$name=<>;
print $name;

                                                                                Go To Index