Kills, reads the question incorrectly, do you want either AoAoH or AoH, depending on whether each line after the first represents the line or all the points that should be built accordingly. Here is how I could write this if every line in the file was to become a line on the chart:
use strict;
use warnings;
use List::Util qw/min max/;
my @x_points = split " ", scalar <>;
my ($x_min, $x_max) = (sort { $a <=> $b } @x_points)[0,-1];
my ($y_min, $y_max) = (0, 0);
my @lines;
while (<>) {
my @y_points = split;
die "invalid file\n" unless @y_points == @x_points;
$y_min = max($y_min, @y_points);
$y_max = min($y_max, @y_points);
push @lines, [
map { { x => $x_points[$_], y => $y_points[$_] } }
0 .. $#x_points
];
}
use Data::Dumper;
print "x min and max $x_min $x_max\n",
"y min and max $y_min $y_max\n",
"data:\n",
Dumper(\@lines);
my $i;
for my $line (@lines) {
$i++;
print "line $i is made up of points: ",
(map { "($_->{x}, $_->{y}) " } @$line), "\n";
}
, , :
use strict;
use warnings;
use List::Util qw/min max/;
my @x_points = split " ", scalar <>;
my ($x_min, $x_max) = (sort { $a <=> $b } @x_points)[0,-1];
my ($y_min, $y_max) = (0, 0);
my @points;
while (<>) {
my @y_points = split;
die "invalid file\n" unless @y_points == @x_points;
$y_min = max($y_min, @y_points);
$y_max = min($y_max, @y_points);
push @points,
map { { x => $x_points[$_], y => $y_points[$_] } }
0 .. $#x_points;
}
use Data::Dumper;
print "x min and max $x_min $x_max\n",
"y min and max $y_min $y_max\n",
"data:\n",
Dumper(\@points);
print "Here are the points: ",
(map { "($_->{x}, $_->{y}) " } @points), "\n";