http://qs321.pair.com?node_id=11129240


in reply to Re^7: Introspecting function signatures
in thread Introspecting function signatures

This can indeed be a good solution. Given that perl will reliably call DESTROY when an object goes out of scope, this could ensure that whatever the object holds will be cleaned up. It is a bit more code to write as we need to call the function, but might be reasonable.
sub test_something { my $tempdir = create_tempdir(); # ... }

I don't know where the idea came from that in Python people include the tests in the main code. Maybe that was the case 10 years ago, but these days the standard is that tests are in separate files called test_SOMETHING.py.