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;

In reply to Re^8: reading a JSON object by anautismobserver
in thread reading a JSON object by anautismobserver

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.