diff --git a/examples/pg.p6 b/examples/pg.p6 index 400388ef..2b984c72 100755 --- a/examples/pg.p6 +++ b/examples/pg.p6 @@ -1,18 +1,20 @@ #!/usr/bin/env perl6 use v6; - -use lib 'lib'; use DBIish; - -BEGIN { - # Windows support - if $*DISTRO.is-win { - # libpq.dll on windows depends on libeay32.dll which in this path - my constant PG-HOME = 'C:\Program Files\PostgreSQL\9.3'; - %*ENV ~= (PG-HOME).fmt( ';%s\bin' ); - %*ENV = (PG-HOME).fmt( '%s\lib\libpq.dll' ); - } +use NativeCall; + +# Windows support +if $*DISTRO.is-win { + # libpq.dll on windows depends on libeay32.dll which in this path + my constant PG-HOME = 'C:\Program Files\PostgreSQL\9.3'; + my $path = sprintf( 'Path=%s;%s\bin', %*ENV, PG-HOME ); + %*ENV = (PG-HOME).fmt( '%s\lib\libpq.dll' ); + + # Since %*ENV = ... does not actually own process environment + # Weird magic but needed atm :) + sub _putenv(Str) is native('msvcrt') { ... } + _putenv( $path); } my $dbh = DBIish.connect("Pg", :database, :user, :password, :RaiseError);