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
|