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

I read in an Excel file and sent it to an output file. I then read in the output file into a multidimensional array.

I know how to access specific elements. That's not the problem. For exemple here is a snippet from the output file:

ID NAME 1 2 M D S
M001 C0001 215 221 401 402 0
M001 C0002 214 217 401 402 0
M001 C0003 189 209 401 402 0
M001 C0004 0 0 401 402 0
M001 C0005 0 0 401 402 0
M002 C0043 149 152 401 402 1
M002 C0044 243 243 401 402 1
M002 C0045 228 244 401 402 1
M002 C0046 116 119 401 402 1
M002 C0047 118 118 401 402 1

Ok, what I need to to print all the alleles for fish M002 and then a line and then for M002

Basically, theoutput needs to be
M001
215 221 214 217 189 209 0 0 0 0

M002
149 152 243 243 228 244 116 119 118 118
Any help would be appreciated?

Replies are listed 'Best First'.
Re: accessing multidimensional arrays
by Abigail-II (Bishop) on Jun 13, 2002 at 16:27 UTC
    I could write a snippet of code that does what you want, but all that does is access specific elements. And you already know how to do that.

    Could you be more specific what your problem is? What code do you already have? What do you think it should do, and what does it do?

    Abigail

Re: accessing multidimensional arrays
by cacharbe (Curate) on Jun 13, 2002 at 17:20 UTC
    I would attack it like this:
    1. Split the line at white space
    2. Create a HoA with the key being M00x
    3. Push the 2 needed data points at the proper array

    Questions?

    C-.

Re: accessing multidimensional arrays
by stefp (Vicar) on Jun 13, 2002 at 17:52 UTC
    That should do it:

    <>; # skeep the first line while(<>) { s/(\w+)// and $seen{$1}++ ? print : print "$1\n$_" } )

    -- stefp -- check out TeXmacs wiki

Re: accessing multidimensional arrays
by Juerd (Abbot) on Jun 13, 2002 at 16:58 UTC