Truncate an array when you have a ref to it?
- From: "A. Farber" <Alexander.Farber@xxxxxxxxx>
- Date: Wed, 27 Aug 2008 13:34:00 -0700 (PDT)
Hello,
I have an object representing a player:
sub new {
my $package = shift;
my $self = {
.......
CHAT => [[], [], []],
};
bless($self, $package);
}
and its CHAT member holds messages
from 3 other players in an array of 3 arrays.
Then I have a method which sends those
messages over a socket to the player:
$aref = $self->{CHAT}->[0];
push @response, 'chat0=' . join '', @$aref;
$self->{CHAT}->[0] = [];
The last line truncates the sub-array
(after the messages have been sent).
I wonder if I can truncate that array by
using the $aref ? Something like $#xxxx = -1;
Thank you
Alex
.
- Follow-Ups:
- Re: Truncate an array when you have a ref to it?
- From: Ted Zlatanov
- Re: Truncate an array when you have a ref to it?
- From: John W. Krahn
- Re: Truncate an array when you have a ref to it?
- Prev by Date: perl multithreading performance
- Next by Date: Re: perl multithreading performance
- Previous by thread: perl multithreading performance
- Next by thread: Re: Truncate an array when you have a ref to it?
- Index(es):
Relevant Pages
|