Jess Balint wrote at Wed, 05 Jun 2002 19:19:15 +0200:

> Hello all. I have trying to push a value onto the end of a two-dimension array. Here 
>is my code.
> 
>                         if( /\s+--\s+COLS\.\s+(\d+)\s+-\s+(\d+)\s+--/ ) {
>                                 push( @{questionpos[$questionno]}, $1 );
>                                 push @questionlength[$questionno], ( $2 - $1
> + 1 );
>                         } elsif( /\s+--COL\.\s+(\d+)\s+--/ ) {
>                                 push @questionpos[$questionno], $1;
>                                 push @questionlength[$questionno], 1;
>                         }
>                         print "Match column definition
> \@$questionpos[$questionno][$#questionpos[$questionno]]\n" if( $d == 1 );
> ...

push @{$questionpos[$questionno]}, $1 
is an example how it should work for you.

In general @array[$index1] is equal to ($array[$index1]),
when it's a little crazy, think that
@array[0,2,4,6] makes really sense.

BTW, you're source code seems to be hard to read.
Especially there are some things double what is a real crime :-)

Try something like:

if (/\s+ -- \s+ COLS \. \s+ (\d+) \s+ -
     (?: (\d+) \s+ -- | -)
    /x) 
{
   push @{$pos[$no]}, $1;
   push @{$length[$no]}, ($2 ? ($2 - $1) : 1);
}

Best Wishes,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to