[ale] perl question
Chris Fowler
cfowler at outpostsentinel.com
Tue Apr 27 14:20:54 EDT 2004
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;
}
More information about the Ale
mailing list