Wide character in null operation at ...

I

islue.hu

My code:

use DB_File;
tie(%FILE => "DB_File", $filename)
or die "Couldn't create $filename database: $!\n";
$key = "\x{296a}";
print "OK!" unless exists $FILE{$key};

I wonder if a unicode character is forbidden as a hash key, or this is
a problem about FILE IO.
 
D

Damian James

My code:

use DB_File;
tie(%FILE => "DB_File", $filename)
or die "Couldn't create $filename database: $!\n";
$key = "\x{296a}";
print "OK!" unless exists $FILE{$key};

I wonder if a unicode character is forbidden as a hash key, or this is
a problem about FILE IO.

The above prints "OK!" with no other message of any kind.
Eliminating the tie() and enabling warnings and strict...

#!/usr/bin/perl
use warnings;
use strict;

my %test = ( "\x{296a}" => 1 );
print "$_: $test{$_}\n" for keys %test;


Gives:

Wide character in print at test line 7.
⥪: 1

OTOH, including:

no warnings 'utf8';

skips the warning. So not sure what the 'void operation' was, the code
you've shown doesn't display it. But perlunicode should tell you something
about the warning you saw.

--damian
 
I

islue

About "Wide character in print ...", this article gives the answer.
http://www.ahinea.com/en/tech/perl-unicode-struggle.html

no other massage?!
I tested more:

#!/usr/bin/perl
use strict;
use warnings;
use DB_File;

my %FILE;
my $filename = 'test.dbm';
tie(%FILE => "DB_File", $filename);

my $key = "\x{296a}";
print "OK!" unless exists $FILE{$key};

Gives:

Wide character in null operation at test.pl line 12.

Without tie():

#!/usr/bin/perl
use strict;
use warnings;
use DB_File;

my %FILE;
#my $filename = 'test.dbm';
#tie(%FILE => "DB_File", $filename);

my $key = "\x{296a}";
print "OK!" unless exists $FILE{$key};

Gives:

OK!

Platform info:
Mandrakelinux release 10.1 (Official) for i586
Kernel 2.6.8.1-12mdk on an i686 / \l
This is perl, v5.8.5 built for i386-linux-thread-multi

So it seems like a problem about "non-unicode filehandle", which
mentioned in the article above. But I am using tie(), which does not
use filehandle.
Is there something like hidden filehandle about it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top