NAME

DBD::PO::Text::PO - read or write a PO file entry by entry

$Id: PO.pm 254 2008-10-21 19:11:47Z steffenw $

$HeadURL: https://dbd-po.svn.sourceforge.net/svnroot/dbd-po/trunk/DBD-PO/lib/DBD/PO/Text/PO.pm $

VERSION

1.00

SYNOPSIS

write

use strict;
use warnings;

use Carp qw(croak);
use English qw(-no_match_vars $OS_ERROR);
require IO::File;
require DBD::PO::Text::PO;

my $file_handle = IO::File->new();
$file_handle->open(
    $file_name,
    '> :encoding(utf-8)',
) or croak "Can not open file $file_name: $OS_ERROR;
my $text_po = DBD::PO::Text::PO->new({
    eol     => "\n",
    charset => 'utf-8',
});

# header
$text_po->write_entry(
    $file_name,
    $file_handle,
    [
        q{},
        'Content-Type: text/plain; charset=utf-8',
    ],
);

# line
$text_po->write_entry(
    $file_name,
    $file_handle,
    [
        'id',
        'text',
    ],
);

read

use strict;
use warnings;

use Carp qw(croak);
use English qw(-no_match_vars $OS_ERROR);
require IO::File;
require DBD::PO::Text::PO;

my $file_handle = IO::File->new();
$file_handle->open(
    $file_name,
    '< :encoding(utf-8)',
) or croak "Can not open file $file_name: $OS_ERROR;
my $text_po = DBD::PO::Text::PO->new({
    eol     => "\n",
    charset => 'utf-8',
});

# header
my $header_array_ref = $text_po->read_entry($file_name, $file_handle);

# line
while ( @{ my $array_ref = $text_po->read_entry($file_name, $file_handle) } ) {
    print "id: $array_ref->[0], text: $array_ref->[1]\n";
}

DESCRIPTION

The DBD::PO::Text::PO was written as wrapper between DBD::PO and DBD::PO::Locale::PO.

 ---------------------
|         DBI         |
 ---------------------
           |
 ---------------------
|      DBD::File      |
|  (SQL::Statement)   |
 ---------------------
           |
 ---------------------
|       DBD::PO       |
 ---------------------
           |
 ---------------------
|  DBD::PO::Text::PO  |
 ---------------------
           |
 ---------------------
| DBD::PO::Locale::PO |
 ---------------------
           |
     table_file.po

SUBROUTINES/METHODS

method new

method write_entry

method read_entry

DIAGNOSTICS

none

CONFIGURATION AND ENVIRONMENT

none

DEPENDENCIES

Carp

English

Params::Validate

DBD::PO::Locale::PO

Socket

INCOMPATIBILITIES

not known

BUGS AND LIMITATIONS

not known

SEE ALSO

DBD::CSV

AUTHOR

Steffen Winkler

LICENSE AND COPYRIGHT

Copyright (c) 2008, Steffen Winkler <steffenw at cpan.org>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.