1)Length of Array:
To find the length of any given array just use a scalar variable and do the following:
$len=@array;
where len is a scalar variable and array is an array variable
We can modify array elements after defining an array.We can add more elements in the array by using following statement :
@array[3..6]=(6,7,8,9);
To find the length of any given array just use a scalar variable and do the following:
$len=@array;
where len is a scalar variable and array is an array variable
Program Code:
#! /Perl/bin/perl
@array=(1,2,3,4,5,6);
$len=@array;
print("Length of array is $len");
Output:
Length of array is 6
2)Array Modification:#! /Perl/bin/perl
@array=(1,2,3,4,5,6);
$len=@array;
print("Length of array is $len");
Output:
Length of array is 6
We can modify array elements after defining an array.We can add more elements in the array by using following statement :
@array[3..6]=(6,7,8,9);
Program Code:
#! /Perl/bin/perl
@array=(1,2,3);
print("Original Array \n@array\n");
@array[3..6]=(6,7,8,9);
print("Array after modification \n@array");
Output:
Original Array
1 2 3
Array after modification
1 2 3 6 7 8 9
#! /Perl/bin/perl
@array=(1,2,3);
print("Original Array \n@array\n");
@array[3..6]=(6,7,8,9);
print("Array after modification \n@array");
Output:
Original Array
1 2 3
Array after modification
1 2 3 6 7 8 9
0 comments:
Post a Comment