you are not creating an array of arrays (AoA), but a simple array whose 4 elements are:my @vector = (4.3125, 0.4375); push @AoA, @vector; @vector = (4.375, 0.375); push @AoA, @vector;
You need to push(4.3125, 0.4375, 4.375, 0.375)
or buildmy @vector = (4.3125, 0.4375); push @AoA, \@vector; @vector = (4.375, 0.375); push @AoA, \@vector;
I guess this should solve your issue.push @AoA, [4.3125, 0.4375]; push @AoA, [4.375, 0.375];
As I said earlier, you should avoid using the $a and $b variables, they are special variables used among other things for sorting, they behave differently from other variables, and using as you do them might lead to difficult-to-track bugs. You may use $c or $d, if you like, this will not be a problem, but I would personally put a more meaningful name helping comprehension of what they represent.
Update: As pointed below by farang the first method above for building an AoA is actually buggy. Use the second one. Thanks to farang for picking that.
In reply to Re^5: enumerating values for slopes
by Laurent_R
in thread enumerating values for slopes
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |