----- Original Message ----- 
From: "Jarvis, John" <[EMAIL PROTECTED]>
To: "'amit hetawal'" <[EMAIL PROTECTED]>
Cc: <[email protected]>
Sent: Wednesday, February 01, 2006 7:23 PM
Subject: RE Multi Dimensional Arrays


> Amit wrote:
>
>
>
> >Hello all,
> >  I am a newbee in perl. Just wanted some guidance so as to how to
> implement multidimensional arrays in perl. I have >to create an 2-d array
> with 26*26 of all the english alphabets so that for each row and column i
> can have a partiulcar >value like a to a =1
> >b to a=2;
> >I am just not getting how to implement this.
> >Can someone suggest something.
> >Thanks
> >Amit.

Here's some code that satisifies your criteria (I think):

use warnings;
@rows = ('a' .. 'z');
@cols = ('a' .. 'z');

for $r(@rows) {
    for $c(@cols) {
       # push a reference to the list ($c, $r) onto @table
        push @table, [$c, $r];
        }
    }

# @table now has the values you're interested in.

$pos = 2;

# $table[1] is a reference to the list (b, a).
# The following line dereferences that list and prints it out.
print "@{$table[$pos - 1]}\n";
__END__

Just check that, for different values for $pos in the range 1 .. 676, it
produces the desired output.

Cheers,
Rob

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to