Created
December 24, 2010 06:41
-
-
Save tomill/753976 to your computer and use it in GitHub Desktop.
PerlIO::via::Samurai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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