Rather than changing the ID, why not give the test another attribute ('validated' for example)?
Then you don't have to worry about collisions with pre-existing IDs when validating.
foreach my $currentTestID (keys %$tests)
{
$tests->{$currentTestID}{validated} = validate($tests->{$currentTe
+stID});
}
sub doValidatedTests
{
my $tests = shift;
doTest($_) foreach ( grep {$tests{$_}{validated}} keys %$tests );
}
When the IDs don't change, you're free to tell the test object what its ID is when you create it, and it will be valid until you drop the test from your hash and the test itself gets garbage collected shortly thereafter. |