Hi Anant,
One more query:-
> HOW TO REMOVE ANY ELEMENT FROM AN ARRAY.
> I mean if i have allocated till arr[5]. Now I want to remove the value
> arr[4] and arr[5]. So how it can be done so that $#arr would tell 3.
>
#!/usr/bin/perl -l
use strict;
use warnings;
my @arr=qw( home father son sun mother drinks);
$#arr=3; # by assigning the the length of array to 3
# one has reduced the array element
# you can also increase the length by assigning an upper
number
# to $, however the element will be empty. <take note>
print $#arr; # print 3
@arr=qw( home father son sun mother drinks);
for(my $i=0;$i<=1;$i++){
pop @arr; # you can also use function "pop" to reduce the
# element of array, here using a for loop to
# iterate twice with pop we removed the last
# two array element
}
print $#arr; # print 3
__END__
Read on these functions=> splice,pop,push,shift and unshift. using perldoc
-f "pop"
Timothy,
Regards.