in reply to Re^7: reading a JSON object
in thread reading a JSON object
Thanks. How do I generalize this to two (or more) dimensions?
For example, the code below selects a subset of the first index (which runs from 0-5).
How do I modify it so it also selects a subset of the second index (which runs from 0-3)?
use strict; use warnings; use Data::Dumper qw(Dumper); my $matrix; my @matrix; $matrix[0][0] = 00; $matrix[1][0] = 10; $matrix[2][0] = 20; $matrix[3][0] = 30; $matrix[4][0] = 40; $matrix[5][0] = 50; $matrix[0][1] = 01; $matrix[1][1] = 11; $matrix[2][1] = 21; $matrix[3][1] = 31; $matrix[4][1] = 41; $matrix[5][1] = 51; $matrix[0][2] = 02; $matrix[1][2] = 12; $matrix[2][2] = 22; $matrix[3][2] = 32; $matrix[4][2] = 42; $matrix[5][2] = 52; $matrix[0][3] = 03; $matrix[1][3] = 13; $matrix[2][3] = 23; $matrix[3][3] = 33; $matrix[4][3] = 43; $matrix[5][3] = 53; print Dumper \@matrix; my @matrix2 = @matrix[0, 2]; print Dumper \@matrix2; my @matrix3 = @matrix[0, 1, 5]; print Dumper \@matrix3;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^9: reading a JSON object
by AnomalousMonk (Archbishop) on May 11, 2022 at 22:53 UTC |