Archive for April, 2010
Perl dead? Not by a long shot…
by bigpresh on Apr.17, 2010, under Perl
With 1162 distributions uploaded to CPAN last month the highest ever – modern Perl is still going strong!
(See also isperldead.com for another opinion…. ;) )
Traditionally, the Perl community has been fairly quiet – probably because we’re all busy getting on and doing things rather than feeling the need to shout about how great our language is, but the Planet Perl Ironman project aims to help change that.
Dancer::Plugin::Database – easy DB connections for Dancer apps
by bigpresh on Apr.15, 2010, under Dancer web framework, Perl
Last night I finished and released the first version of Dancer::Plugin::Database, a plugin for the Dancer web framework to provide easy database connections using the venerable DBI.
It takes the database connection details from the app config file, and provides a database keyword which will return you a connected database handle (taking care of ensuring that the DB connection is still alive, etc).
So, usage can be as simple as:
my $books = database->selectall_arrayref( 'select * from books where author = ?', { Slice => {}}, $author );
(Calling database() simply returns a DBI database handle, so you can obviously do anything you can do with DBI).
Also, at the moment, if a database connection could not be established for any reason, database() will just return undef, so you will need to handle errors appropriately. After considering whether it’s wise, I may tweak it to die, so that Dancer will handle the failure with a pretty 500 error for you (in which case, I’ll make it possible to disable that via the config).
Resizing ext2/3 filesystem in loop file
by bigpresh on Apr.06, 2010, under Linux, System Administration
Quick post, mostly for my own future reference, as I couldn’t quite remember how to resize an ext3 filesystem contained in a file.
dd if=/dev/zero of=disk.img bs=1M count=1024 oflag=append conv=notrunc e2fsck -f disk.img resize2fs disk.img
The above will append 1GB to the end of the file, then resize the ext2/3 filesystem to take up that newly-added space.