Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: "wide character in print" error in DBM::Deep

by ikegami (Pope)
on Mar 22, 2010 at 20:10 UTC ( #830155=note: print w/replies, xml ) Need Help??


in reply to "wide character in print" error in DBM::Deep

Here's a test program:

#!/usr/bin/perl use strict; use warnings; use Test::More tests => 8; use Data::Dumper qw( Dumper ); use DBM::Deep qw(); use File::Temp qw( tempfile ); my ($fh, $fn) = tempfile(); my $db = DBM::Deep->new( $fn ); sub _u { utf8::upgrade( my $s = $_[0] ); $s } sub _d { utf8::downgrade( my $s = $_[0] ); $s } $db->{A} = "\x61"; $db->{B} = _d("\xA0"); $db->{C} = _u("\xA0"); $db->{D} = "\x{2660}"; $db->{"\x61" } = 1; $db->{_d("\xA0")} = 1; $db->{_u("\xA0")} = 1; $db->{"\x{2660}"} = 1; my @keys = sort keys %$db; is( 0+@keys, 7, "Num keys" ) or diag('Got ' . do { local $Data::Dumper::Useqq = 1; local $Data::Dumper::Terse = 1; local $Data::Dumper::Indent = 0; Dumper(\@keys) }); is( $keys[4], "\x61", "7-bit key" ); is( $keys[5], "\xA0", "8-bit key" ); is( $keys[6], "\x{2660}", "32-bit key" ); is( $db->{A}, "\x61", "7-bit val" ); is( $db->{B}, "\xA0", "8-bit val (UTF8=0)" ); is( $db->{C}, "\xA0", "8-bit val (UTF8=1)" ); is( $db->{D}, "\x{2660}", "32-bit val" );

Output:

1..8 Wide character in print at /home/eric/lib/perl5/DBM/Deep/File.pm line +193. # Looks like your test exited with 9 before it could output anything.

To validate the test, I ran it after replacing
my $db = DBM::Deep->new( $fn );
with
my $db = {};

Update: Fixed bugs in test.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://830155]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2018-06-21 21:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (119 votes). Check out past polls.

    Notices?