Remiah: thank you for your latest post - it's great, I learned a lot from it. But, there is still a little problem. Consider the following script:
use strict; use warnings;
use 5.014;
use Win32::Console;
use autodie;
use warnings qw< FATAL utf8 >;
use Carp; use Carp::Always;
use utf8;
use Fcntl;
use DB_File;
use DBM_Filter;
my ($i, $FileName);
my (@Tied);
binmode STDOUT, ':encoding(UTF-8)';
binmode STDERR, ':encoding(UTF-8)';
binmode $DB::OUT, ':encoding(UTF-8)' if $DB::OUT; # for the debugger
Win32::Console::OutputCP(65001); # Set the console code page t
+o UTF8
$FileName = 'E:\\My Documents\\Technical\\Perl\\Eclipse workspace\\Wor
+k\\'Tie File test.txt';
my $db = tie @Tied, 'DB_File', $FileName, O_CREAT | O_RDWR, 0644, $DB_
+RECNO;
$db->Filter_Push('encode' => 'UTF-8');
while (<DATA>) {
push @Tied, $_;
} # end while (<DATA>)
$i =0;
foreach (@Tied) {
print "$i $_";
++$i;
} # end foreach (@Tied)
$db->Filter_Pop();
untie $FileName;
__DATA__
τι κάνετε;
πάρτε το ή αφή&
+#963;τε το
שלום חברים
abc לא כןכן efg
מתי ולאן This is it
מעכשיו לעכש
+;יו
Σήμερα είναι &#
+932;ρίτη
Θέλω να φάω
τι κάνετε;
(It's practically identical to your latest script). Notice that on purpose, I took away the "chomp" on input to the tied array, and indeed, as you can see from the script print (STDOUT) output, the array members do have "\r\n" terminations. But, inspecting the saved tied file, it turns out that the records _do_not_ have newlines (or \r\n) terminations! Why is that, and what should be done? (Maybe something in $db->Filter_Push())? And how? In addition, can you refer us to a good documentation for DB_File and DBM_Filter modules? Many TIA Helen |