ry 16, 2003 4:27 PM
To: Liss, Mike
Cc: '[EMAIL PROTECTED]'
Subject: Re: Adding to multi-dimensional array dynamically via push...
push( @MyArray[ 0 ], 0 );
Hi Mike,
I think you need to make up your mind who's doing the work here--you or
Perl. The stack functions, push and pop, are i
push( @MyArray[ 0 ], 0 );
Hi Mike,
I think you need to make up your mind who's doing the work here--you or Perl. The
stack functions, push and pop, are intended to let the array handle its own
organization, while you concern yourself only with the top element [ie the one most
recently insert
Rob Dixon wrote:
> If you want to use push, pop, shift, unshift etc then do
>
> push @$MyArray[$i], $val
Sorry:
push @{$MyArray[$i]}, $val
>
> which (if the array was previously empty) will set $MyArray[$i][0] to
> $val.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional com
Mike Liss wrote:
>
> Hello,
Hello,
> I would like to know if it is possible to do somthing like this:
>
> ( I know I can't do it this way as Perl barfs when I tried it )
>
>
> $SizeOfMyArray = 2;
>
> $MyArray[ $SizeOfMyArray ];
If you want to pre-allocate the array size the proper way to do
Mike Liss wrote:
> I am trying to create a multi-dimensional array
>
> $MyArray[ $SizeOfMyArray ];
>
You don't do that in Perl. There is no equivalent to BASIC's DIM
statement.
>
> So I can do this:
>
> print " $MyArray[ 0 ][ 0 ] \n";
You can do exactly that if you want to. The array will automa
Mike Liss wrote:
>
> I am trying to create a multi-dimensional array
>
> $MyArray[ $SizeOfMyArray ];
>
> So I can do this:
>
> print " $MyArray[ 0 ][ 0 ] \n";
>
>
> And what I want to do is add items to the array dynamically
in Perl, multi-dimensional array is usually implemented with array
print " $MyArray[ 0 ][ 0 ] \n";
>
>
> And what I want to do is add items to the array dynamically
>
>
>
>
>
>
> -Original Message-
> From: Mark Anderson [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 1:47 PM
> To: Liss, Mike;
ED]]
Sent: Wednesday, January 15, 2003 1:47 PM
To: Liss, Mike; [EMAIL PROTECTED]
Subject: RE: Adding to multi-dimensional array dynamically via push...
> I would like to know if it is possible to do somthing like this: ( I
> know I can't do it this way as Perl barfs when I tried it )
&
> I would like to know if it is possible to do somthing like this:
> ( I know I can't do it this way as Perl barfs when I tried it )
>
> $SizeOfMyArray = 2;
>
> $MyArray[ $SizeOfMyArray ];
Why are you trying to define the size of your array?
> push( @MyArray[ 0 ], 0 ); << --- complains