my $results; my $test_data = [qw{foo bar baz}]; { no strict 'refs'; local $^W; # suppres redefined warnings my $arrayref_called = 0; local *{'DBI::fetchrow_arrayref'} = sub {$arraref_called++; $test_data }; $results = some_func($some_arg); is($arrayref_called, 1, '... and fetchrow_arrayref should be called only once'); } ok($results, '... and some_func succeeded'); is_deeply($results, $test_data, '... and it should return the correct data');