Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Is this the correct structure?

by code-ninja (Scribe)
on Jul 05, 2013 at 12:22 UTC ( [id://1042700]=note: print w/replies, xml ) Need Help??


in reply to Is this the correct structure?

The simplest way to do this can be:

use strict; use warnings; my @AoA; while(<STREAM>){ chomp; next if (/METHOD/); push @AoA, [split /\s+/]; } print \@AoA; __DATA__ METHOD 0TM 1TM 2TM >2TM method1 3 68 18 10 method2 3 80 10 6 method3 3 87 9 1 method4 5 83 9 3 method5 6 75 15 4 method6 14 77 6 3 method7 12 82 2 3 method8 9 84 3 3 method9 13 68 16 3 method10 5 65 20 9 method11 9 64 20 7 method12 5 68 18 9 method13 6 82 9 2 method14 11 79 8 2 method15 6 69 20 5 method16 5 80 11 3 method17 1 68 17 14

What happens here is, the split "tokenizes" each line assuming the space between the words as the delimiter. The square brackets around the split create a reference to an anonymous array which is pushed into the array of arrays data structure.

UPDATE

Umm 2teez already said what I wrote above... I did not check the replies before posting... mesa bad.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1042700]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found