At 01:09 PM 7/30/2001 +0530, 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?
First, by passing an explicit reference:
$ perl -Mstrict -w
sub mypop { pop @{$_[0]}; }
my @a = qw(one two three);
print "@a\n";
mypop(\@a);
print "@a\n";
^D
one two three
one two
Second, by making an implicit reference using a prototype (warning:
subroutine declaration must precede use):
$ perl -Mstrict -w
sub mypop (\@) { pop @{$_[0]}; }
my @a = qw(one two three);
print "@a\n";
mypop @a;
print "@a\n";
^D
one two three
one two
Peter Scott
[EMAIL PROTECTED]
http://www.perldebugged.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]