There's more than one way to do things | |
PerlMonks |
Re^3: Converting python list range expressions to perlby kcott (Archbishop) |
on Dec 04, 2022 at 18:45 UTC ( [id://11148553]=note: print w/replies, xml ) | Need Help?? |
"Ken, thanks for your writeup, including forcing me to learn a bit about Test -- I needed that! :-)" You're welcome. It's good to be able to start a script with use v5.36;. "I'd rather stick with Perl's slice capability since it reads more cleanly (to me, anyway) ..." What you choose is entirely up to you. This correlation stood out for me:
"... and doesn't require copying and modifying the source array." The source array, @test_array, is not modified at all. The temporary copy, @temp_array, is modified in the last statement of (my) get_array_slice_by_python_expr() function; it's then immediately discarded as it goes out of scope. I added your three new tests, plus a fourth ([:]), to my original code:
All pass:
— Ken
In Section
Seekers of Perl Wisdom
|
|