S
Sean Nakasone
Below I have a simple script that will build an array then delete an
element from it. After deleting the element, the size of the array still
remains the same. I'm a perl newbie and would like to know the correct
way to delete an array element and to obtain the new array size.
use strict;
use warnings;
my @arr = (1, 2, 3);
print @arr; # outputs "123"
my $size = @arr;
print "\nsize=$size\n";
delete $arr[1];
print @arr; # outputs "13"
$size = @arr;
print "\nsize=$size\n"; # this is still 3, why??
element from it. After deleting the element, the size of the array still
remains the same. I'm a perl newbie and would like to know the correct
way to delete an array element and to obtain the new array size.
use strict;
use warnings;
my @arr = (1, 2, 3);
print @arr; # outputs "123"
my $size = @arr;
print "\nsize=$size\n";
delete $arr[1];
print @arr; # outputs "13"
$size = @arr;
print "\nsize=$size\n"; # this is still 3, why??