2009/02/26


IO::Lambdaを見てて、おーいいねー、と思ってサンプル動かしたらエラー出た。
追ってくと、IOなんて根底のモジュールに原因がある事が分かった。原因っていうかエラーが出るように仕込んであった。
以下パッチ作ってオフィシャルにメールした。
--- IO.xs.orig  2006-03-26 11:27:13.000000000 +0900
+++ IO.xs   2009-02-24 20:16:34.921875000 +0900
@@ -121,7 +121,12 @@
     }
     return RETVAL;
 #else
+#  ifdef WIN32
+   unsigned long flags = block;
+   return ioctl(PerlIO_fileno(f), FIONBIO, &flags);
+#  else
     return -1;
+#  endif
 #endif
 }
 
もしかしたらFAQなpatchで蹴られるだろうけど...

追記 2009/02/26
patchがマージされました。
Posted at by



2009/02/24


なんかlibmemcachedはMLにパッチ送っても反応無いし、Cache::Memcached::Fastの方が速いという噂なので、Cache::Memcached::FastをWindowsに移植してみた。
http://svn.coderepos.org/share/lang/perl/Cache-Memcached-Fast-0.12/
オリジナルからの差分は svn diff -r19958
で取得して下さい。
リポジトリを作成し直しました。最新取得しなおして下さい。
チェックアウトしてそのままビルドして頂いてもいいです。libmemcachedはgccとVisual Studioをサポートしましたが、今回はgcc限定にしました。
よろしければ、どうぞ。
Posted at by



2009/01/07


im.kayac.comに送信するperlスクリプト。
コードだけ。
#!/usr/bin/perl
use strict;
use warnings;

use Encode;
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
use Config::Pit;
use Digest::SHA1 qw(sha1_hex);
use JSON;

if ($^O eq 'MSWin32') {
    eval {
        require Win32::API;
        Win32::API->Import('kernel32', 'UINT GetACP()');
        Encode::from_to($ARGV[0], 'cp'.GetACP(), 'utf-8');
    };
}

my $config = pit_get("im.kayac.com", require => {
        "username" => "your username on im.kayac.com",
        "password" => "your password(or secretkey) on im.kayac.com",
        "authtype" => "auth type on im.kayac.com: none/password/secretkey",
    });

my %data = ( message => shift );
die "should be specify message" unless $data{message};
$data{password} = $config->{password} if $config->{authtype} eq "password";
$data{sig} = sha1_hex($data{message} . $config->{password}) if $config->{authtype} eq "secretkey";

my $ua = LWP::UserAgent->new;
my $res = from_json($ua->post(
    "http://im.kayac.com/api/post/$config->{username}", \%data,
    "Content-Type" => "application/x-www-form-urlencoded"
)->decoded_content);

print $res->{result}.$res->{error};
Posted at by