Lingua-PTD
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Lingua/PTD/BzDmp.pm view on Meta::CPAN
sub new {
my ($class, $filename) = @_;
my $self;
bunzip2 $filename => \$self or die "Failed to bunzip: $Bunzip2Error.";
{
no strict;
$self = eval $self;
die $@ if $@;
}
bless $self => $class #amen
}
sub _save {
my ($self, $filename) = @_;
my $z = new IO::Compress::Bzip2 $filename, encode => 'utf8' or return 0;
binmode $z, ":utf8";
select $z;
$self->dump;
$z->close;
lib/Lingua/PTD/Dumper.pm view on Meta::CPAN
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2010-2014 by Alberto Manuel Brandão Simões
=cut
sub new {
my ($class, $filename) = @_;
my $self = do(abs_path($filename));
bless $self => $class #amen
}
sub _save {
my ($self, $filename) = @_;
open OUT, ">:utf8", $filename or return 0;
select OUT;
$self->dump;
close OUT;
lib/Lingua/PTD/JSON.pm view on Meta::CPAN
my $contents;
{
local $/;
undef $/;
open IN, "<:utf8", $filename or return 0;
$contents = <IN>;
close IN;
}
my $self = decode_json($contents);
bless $self => $class #amen
}
use Data::Structure::Util qw( unbless );
sub _save {
my ($ptd, $filename) = @_;
my $type = ref $ptd;
# a.k.a. DAMN!
$ptd = unbless $ptd;
open OUT, ">:utf8", $filename or return 0;
lib/Lingua/PTD/SQLite.pm view on Meta::CPAN
sub new {
my ($class, $filename) = @_;
my $dbh = DBI->connect("dbi:SQLite:dbname=$filename", "", "",
{ sqlite_unicode => 1} ) or die "Cant connect to database";
my $self = {
dbh => $dbh,
get_meta => $dbh->prepare("SELECT v FROM meta WHERE k = ?;"),
get_occs => $dbh->prepare("SELECT occ FROM occs WHERE w = ?;"),
exists => $dbh->prepare("SELECT w FROM trans WHERE w = ?;"),
};
bless $self => $class # amen
}
sub trans {
my ($self, $word, $trans) = @_;
if ($trans) {
my $sth = $self->{dbh}->prepare("SELECT p FROM trans WHERE w = ? AND t = ?;");
$sth->execute($word, $trans);
my @row = $sth->fetchrow_array;
return (@row)?1:0;
} else {
lib/Lingua/PTD/XzDmp.pm view on Meta::CPAN
sub new {
my ($class, $filename) = @_;
my $self;
unxz $filename => \$self or die "Failed to unxz: $UnXzError.";
{
no strict;
$self = eval $self;
die $@ if $@;
}
bless $self => $class #amen
}
sub _save {
my ($self, $filename) = @_;
my $z = new IO::Compress::Xz $filename, encode => 'utf8' or return 0;
select $z;
$self->dump;
$z->close;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.990 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )