Skip to content

Instantly share code, notes, and snippets.

@tomill
Created December 24, 2010 06:41
Show Gist options
  • Save tomill/753976 to your computer and use it in GitHub Desktop.
Save tomill/753976 to your computer and use it in GitHub Desktop.
PerlIO::via::Samurai
package PerlIO::via::Samurai;
use strict;
use warnings;
use Encode;
use Acme::Samurai;
sub import {
binmode STDOUT => ':via(Samurai)';
}
sub PUSHED {
my ($class, $mode, $fh) = @_;
bless {}, $class;
}
sub WRITE {
my ($self, $buf, $fh) = @_;
print $fh $self->gozaru($buf);
1;
}
sub gozaru {
my ($self, $text) = @_;
$text = Encode::decode_utf8($text);
$text = Acme::Samurai->gozaru($text);
Encode::encode_utf8($text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment