J
Jan Fure
Hi;
I the code below, I am creating a data structure of array references.
I want to loop through the keys, and for each key, which corresponds
to multiple values, I want to dereference the data to get a plain
array containing the values. I have read 'perlref', but it is still
not clear to me.
I made the code based on the 'Hashes with Multiple Values Per Key'
from the Perl Coocbook, and also inspired by some posts to this group.
I used Data:umper to see that I have the right data.
my %data;
for $row ( @DATA2 ){ #@DATA2 is an array of arrays
push @{ $data{$$row[0]} }, $$row[1];
}
my @points;
foreach ( sort { $a <=> $b } keys %data ) {
@{$data{$_}} = sort { $a <=> $b } @{$data{$_}};
push @{$points[0]}, $_;
push @{$points[1]}, $data{$_};
}
I the code below, I am creating a data structure of array references.
I want to loop through the keys, and for each key, which corresponds
to multiple values, I want to dereference the data to get a plain
array containing the values. I have read 'perlref', but it is still
not clear to me.
I made the code based on the 'Hashes with Multiple Values Per Key'
from the Perl Coocbook, and also inspired by some posts to this group.
I used Data:umper to see that I have the right data.
my %data;
for $row ( @DATA2 ){ #@DATA2 is an array of arrays
push @{ $data{$$row[0]} }, $$row[1];
}
my @points;
foreach ( sort { $a <=> $b } keys %data ) {
@{$data{$_}} = sort { $a <=> $b } @{$data{$_}};
push @{$points[0]}, $_;
push @{$points[1]}, $data{$_};
}