[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] perl question
- Subject: [ale] perl question
- From: cfowler at outpostsentinel.com (Chris Fowler)
- Date: Tue Apr 27 14:20:54 2004
- In-reply-to: <[email protected]>
- References: <1083087859.17414.117.camel@devel> <[email protected]>
On Tue, 2004-04-27 at 14:11, michael d. ivey wrote:
> On Tue, Apr 27, 2004 at 01:44:20PM -0400, Chris Fowler wrote:
> > #
> > # I need to determine the number of objects
> > # in the array so I can append to it.
> > #
>
> Well, that's not really true. push and unshift will add things to an
> array without knowing the length. splice and -1 indexing could also do
> it.
>
> However, '$length = scalar @array' gives you the number of elements, and
> $#array gives you the number - 1.
>
> Does that help?
Makes perfect sense.
Is the the correct way to add that data?
sub add_escalation_group {
my $self = shift;
my($id, $timeout) = @_;
#
# create a new hash for this
# data
#
my $h = { 'id' => $id, 'timeout' => $timeout, };
#
# add it to arrat
#
push @{$self->{'escalationgroups'}}, $h;
}