Hi, I know that if you have an array say @foo, to get the number of elements in that array you can do $#foo.
However, I am having trouble doing this with an array that was passed into a function as a pointer. Something like this:
@foo = ("1","2","3"
;
sub1(\@foo);
sub sub1
{
my ($foo) = @_;
push @$foo , "4";
print $#foo;
}
It keeps giving me -1 for the length of array.
please help thanks.
However, I am having trouble doing this with an array that was passed into a function as a pointer. Something like this:
@foo = ("1","2","3"
sub1(\@foo);
sub sub1
{
my ($foo) = @_;
push @$foo , "4";
print $#foo;
}
It keeps giving me -1 for the length of array.
please help thanks.