> -----Original Message-----
> From: Narendran Kumaraguru Nathan [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 30, 2001 6:08 AM
> To: [EMAIL PROTECTED]
> Subject: [Fwd: Re: how can an element in a array be deleted
> from a subroutine ?]
>
>
>
> Hai all,
> I have found it myself, using splice, it is working.
> Naren.
>
> Narendran Kumaraguru Nathan wrote:
>
> > Hai all,
> > I have a local array and I wish to delete the last
> element of the
> > array from the subroutine. I pass the array as reference
> and tried as
> > pop(@array_neme); this didn't work. Is there a way I can do it?
> > Thanks & Regards,
> > Naren.
Note that pop() is just a special case of splice(), so using pop() should
work to remove the last element in an array.
You mention passing a reference to a sub, but your pop() call doesn't
dereference. A sub to remove the last element from an array would look like:
sub remove_last
{
my $aref = shift;
pop @$aref; # note dereference
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]