in reply to Re^2: 2 dimensional array
in thread 2 dimensional array

That code leaves table as the one-dimensional array:
@table = ( "ADESFJRASLXDFRT\n" "QBRAINOUEWHGYED\n" "RIRURLKUNGEASDV\n" "NAOBXCSTACHUIOL\n" "OJKDGKJGHJUINHR\n" "AHRHOAIDFSETRGH\n" "RXANOGSYEROGATS\n" "TOUDOGSDSAVFTRY\n" "UORTUOFRHRJUIKO\n" "BTIARTHYEUVFGQA\n" );
But then you access it as if it were a two-dimensional array. (Your code actually will try to use symbolic references; you should enable strict so that when that happens by accident, you are alerted to it.)

So, you need to add the code that would turn the above into a two dimensional array. What is each column going to be?

You probably want to chomp(@data) after reading it to get rid of the newlines.

Replies are listed 'Best First'.
Re^4: 2 dimensional array
by mountain_drew (Initiate) on Jun 23, 2008 at 08:29 UTC
    ok. i see what you're saying. i tried chomping the newlines after i created the table but that still doesn't work. can you suggest a way i can create the table so that it is a 2 dimensional array.
      Loop over the data lines from the file, after chomping them (or chomp in your loop). For each one, split it into individual characters. Just as you split on a comma with split /,/, split between characters with split //. Either add as a new row to table with push @table, [ LIST ], or just treat the uninitialized @table element as an array and it will become one: @{ $table[$row] } = ( LIST ).