- {}
Test blocks (use subtest instead)
You can also invent new names for the variables but there are only so many names you can reasonably use for the same kind of data.
The best solution probably is to put the individual pieces into anonymous blocks. That serves several purposes. First of all it makes clear to both the writer of the code and the reader that the blocks are mostly independent. It also ensures that the variables used in one block won't interfere with the variables in the other block. You'll even have to define these variables in both blocks.
examples/test-perl/t/blocks.t
use strict; use warnings; use MyTools; use Test::More tests => 2; { my $result = sum(1, 1); is $result, 2, '1+1'; } { my $result = sum(2, 2); is $result, 4, '2+2'; }