in reply to accessing array items
my @data = map { [split] } <DATA>;
Or, spelt out step by step...
my @data; while ( <DATA> ) { #for each line of data my @row = split; #split on whitspace push @data, \@row; #push a reference to the row } print "$data[0][0]\n"; #-2.65 print "$data[1][0]\n"; #-2.6 print "$data[1][1]\n"; #-2.0532e-006 print "$data[1][2]\n"; #2.0569e-006 __DATA__ -2.65 -2.0865e-006 2.0831e-006 -2.6 -2.0532e-006 2.0569e-006 -2.55 -2.0215e-006 2.0262e-006
You didn't mention where the data originally comes from, so we can't help you with that.
See split, map and the Perl Data Structures Cookbook for more details.
|
|---|