Truncate an array when you have a ref to it?



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



.



Relevant Pages

  • Re: Which is faster - hash or array lookup
    ... I am suite sure that perl is not The Right Tool ... Each player has 5 pieces, and additionally there is a common ... whereas traversing an array looking for $n is slow). ...
    (comp.lang.perl.misc)
  • Array/Pointer is causing a STATUS_ACCESS_VIOLATION is g++
    ... I have two classes, Player and CardDeck. ... array called drawCards. ... from the player array a card (an int value) out of the drawCards array. ...
    (comp.lang.cpp)
  • Re: How can I do this?
    ... of course a seperate .cpp file containing the class ... My problem is that in main I have an array of class Player, ... The most _trivial_ way would be to pass a pointer to the first element ...
    (comp.lang.cpp)
  • [LogoForum] Re: Updating a value in a list
    ... The message below is being cross-posted from LogoForum. ... If you want to grab the third item- you need to do first bf bf 'yourlist ... You are thinking of an array, which allows you direct access at ... talking about a 'table' of player position. ...
    (comp.lang.logo)
  • Re: Truncate an array when you have a ref to it?
    ... I have an object representing a player: ... my $package = shift; ... from 3 other players in an array of 3 arrays. ... The last line truncates the sub-array ...
    (comp.lang.perl.misc)