Day 115: More Pugs/Perl5 fun

autrijus on 2005-05-27T03:45:00

See clkao's journal. Also note that we can pass coro {...} to Perl 5 land too.

This also works:

#!/usr/bin/pugs

use v6;
use DBI--perl5;
# use perl5:DBI; # in Pugs 6.2.8+, write this instead

unlink 'test.db';

my $dbh = DBI.connect('dbi:SQLite:dbname=test.db');
$dbh.do("CREATE TABLE Test (Project, Pumpking)");

my $sth = $dbh.prepare("INSERT INTO Test VALUES (?, ?)");
$sth.execute();
$sth.execute();
$sth.execute();

my $res = $dbh.selectall_hashref('SELECT * FROM Test', 'Pumpking');

# Just another Pugs hacker
say "Just another $res hacker";

Still lots of things left to do -- I want to share runloop as much as possible, so $CALLER::x can see into Perl 5 lexicals, and maybe reify the control stack both ways via Coro.pm if it's installed. But this is already quite usable for real-world scripting... I'm so excited. :-)