Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^6: Tie::File failing with Unicode/UTF-8 encoding?

by remiah (Hermit)
on Nov 08, 2012 at 10:29 UTC ( #1002869=note: print w/ replies, xml ) Need Help??

in reply to Re^5: Tie::File failing with Unicode/UTF-8 encoding?
in thread Tie::File failing with Unicode/UTF-8 encoding?

Hello HelenCR.

I just thought setting bval option would solve this crlf problem, but DB_File allows only one byte for record delimitor (sorry, I didn't know this ...). DB_File document says

Also note that the bval option only allows you to specify a single byte as a delimiter.

So as you say, Filter_Push for crlf will work.

my @Tied; my $Filename='087.txt'; my $dbh = new DB_File::RECNOINFO ; $dbh->{bval}="\n"; #set bval explicitly my $db = tie @Tied, 'DB_File', $Filename, O_CREAT | O_RDWR, 0644, $dbh or die "failed top open $Filename"; #utf8 $db->Filter_Push('encode' => 'UTF-8'); #add crlf filter $db->Filter_Push( Fetch => sub { s/\r\n$/\n/;}, #convert crlf to lf Store => sub { $_ .="\r"; }, #add cr ); # ... same as before
For documents, I like HTML pages of
And you will have "t" directory for each modules, which is for testing. Scripts in "t" directory gives me hints for usages.

regards, good luck.

Comment on Re^6: Tie::File failing with Unicode/UTF-8 encoding?
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1002869]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2015-11-29 03:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (746 votes), past polls