in reply to Selecting Ranges of 2-Dimensional Data

Reinventing the wheel wasn't too terrible... I'm still interested whether it was necessary! ;-)

Replies are listed 'Best First'.
Re^2: Selecting Ranges of 2-Dimensional Data
by Aldebaran (Curate) on Oct 26, 2018 at 22:30 UTC

    I think that part of testing code is trying to understand it and then giving it more cases. In order for me to see what is happening here, I had to add a routine to print the array as we are accustomed to seeing 2d arrays. I had to add a bunch of say statements to suss out the internals. I got my first look at is_deeply, where the 3rd argument $test_name must be optional:

    is_deeply is_deeply( $got, $expected, $test_name );

    I'm also new with the syntax involving alias, so I printed out values to form a question there. I added a test to substitute in an 'M', intentionally causing the ultimate test to fail, to see if it would. I'll list output and then source between readmore tags:

    Q1) What is the purpose of using alias in this line

    alias my $r = $$range[$i];

    when it goes out of scope at the end of the loop?

    I always enjoy reading your posts, haukex, finding them challenging in the right way. I hope you don't resent me "embellishing" on your script.

      What is the purpose of using alias in this line alias my $r = $$range[$i];

      It was just to shorten code, and play around with Data::Alias a bit. Since LanX showed that the module isn't necessary (because the elements of @_ are already aliases), I removed it and posted an updated getsubset here.

      I hope you don't resent me "embellishing" on your script.

      Not at all, do whatever you need to figure stuff out, that's why I post publicly :-)