( { error => sub { get('username') ne 'myuser' ? "Access denied -- username must be 'myuser'." : undef } }, # # Some simple examples similar to the ones at # http://datacharmer.blogspot.com/2007/06/your-first-macros-with-mysql-proxy.html # { match => qr{^ls\s*(.*)}io, rewrite => sub { $_[1] eq '' ? "SHOW DATABASES" : "SHOW TABLES FROM $_[1]" }, }, { match => qr{^cd\s*(.*)}io, rewrite => sub { "USE $_[1]" }, }, { match => 'info', rewrite => 'SELECT USER(), NOW()' }, { match => qr{^SLECT}io, rewrite => sub { $_[0] =~ s{^SLECT}{SELECT}io; return $_[0] } }, { match => 'hello', columns => ['Hello','World'], data => [ ['first-left','first-right'], ['second-left','second-right'] ] }, # # Final rule - Forward all other queries as they are to the default DBH # { match => qr{(.*)}o } );