pablo has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a script (on a HP-UX Box) which creates a 2-D array, and the compiler is complaining of the syntax. I am trying to write to an array as follows:
$RSB_ARRAY[$counter][$rsb_counter]=$rsb_amount;
The compiler is grumbling about the square brackets bit, with the following message:
syntax error in file ./locks.pl at line 73, next 2 tokens "] [".
Can someone please advise me on he correct syntax. Thanks.

Replies are listed 'Best First'.
Re: Creating a 2-D array.
by merlyn (Sage) on Jan 02, 2001 at 22:54 UTC
    That's Perl 4 screaming at you. Old dead Perl4. Time to upgrade to something released within the last seven years.
      See and I was going to say it looked like a shell problem. I'm so glad I don't have Perl4 errors floating around in my brain. I was lucky and started out with perl 5.00x and the Pink Camel. I used to complain but starting out with a 5.x book and 4.036 perl would surely be worse. =) Plus, HP-UX... *shudder* Why did they call it HP-UX? Because it is only half of Unix... =)

      --
      $you = new YOU;
      honk() if $you->love(perl)

      Thanks, I haven't got a clue what version of Perl I have been utilising - is there a simple way I can check? I can then get someone to get it sorted.
Re: Creating a 2-D array.
by salvadors (Pilgrim) on Jan 02, 2001 at 22:39 UTC
    I don't think the error is where you think it is. For example this code compiles and runs just fine:
    my @RSB_ARRAY; my $counter = 1; my $rsb_counter = 2; my $rsb_amount = 10; $RSB_ARRAY[$counter][$rsb_counter]=$rsb_amount; print "Value = $RSB_ARRAY[$counter][$rsb_counter]\n";

    Perhaps you should strip your code down until you can post a 4 or 5 line fully contained piece of code that exhibits the problem, and then post it?

    (Although often you'll find when you do this you don't actually need to post it, as you'll have already found the problem yourself by them!)

    Thanks,

    Tony

Re: Creating a 2-D array.
by tune (Curate) on Jan 03, 2001 at 00:39 UTC
    try this:
    $RSB_ARRAY->{$counter, $rsb_counter} = $rsb_amount;

    -- tune