hosted services
This page is a brain dump from using perl. Mostly with postgres and the few problems that I have encountered.
Firstly, this is something that caught be by surprise. When you execute a statement, such as the one below, the result set will be held in memory by the perl process.
$sth = $dbh->execute( "select * from t" );
It does not matter which type of fetch you do following this, the result will end up in the perl process. See the following note:
This is a shame since it means that very large select result would be inefficient and potentially cause the system to swap.
tests
A nice way to test your perl code is to use Test::Simple
:
use Test::Simple;
use strict;
use warnings;
sub main {
# ...
}
sub my_func {
my $t = shift;
return "wibble";
}
sub tests {
ok( my_func("flibble") eq "wibble", "test_flibble" );
}
if ( grep (/^--unittest$/, @ARGV )) {
tests();
exit;
}
main();