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

logie17 has asked for the wisdom of the Perl Monks concerning the following question:

Dearest Monks, I am just getting my feet wet with DBD::Mock. I've read through the POD for the module and also have read an excellent article on Perl.com - Perl Code Kata: Testing Databases. However I'm getting tripped up on an aspect of the DBD::Mock::Session object. When you create your statement, result pairs you can can have statement point to a CODE ref. The documentation says this can be used as a sort of catch all but I'm not able to grasp a good example of using this. I found this example:
statement => sub { my $parser1 = SQL::Parser->new('ANSI'); $parser1->parse(shift(@_)); my $parsed_statement1 = $parser1->structure(); delete $parsed_statement1->{original_string}; my $parser2 = SQL::Parser->new('ANSI'); $parser2->parse("UPDATE users SET login_failures = (login_failures + 1) WHERE user_id = 1"); my $parsed_statement2 = $parser2->structure(); delete $parsed_statement2->{original_string}; return Dumper($parsed_statement2) eq Dumper($parsed_statement1); }, results => [[ 'rows' ], []]

However, I'm guessing if it finds parser2 statement and matches the supplied statement returns a true result. What are some other good examples/needs of using a ref to the statement key? (just trying to understand this functionality)
s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;