I'm processing some data from XML files in perl and wanna use the FIFO File::Queue to divide and speed up the process. One perl script parses the XML file and prepares JSON output for another script:
#!/usr/bin/perl -w
binmode STDOUT, ":utf8";
use utf8;
use strict;
use XML::Rules;
use JSON;
use File::Queue;
#do the XML magic: %data contains result
my $q = new File::Queue (File => './importqueue', Mode => 0666);
my $json = new JSON;
my $qItem = $json->allow_nonref->encode(\%data);
$q->enq($qItem);
As long %data
contains numeric and a-z data only this works fine. But when one of the widechars occurs (eg. ł, ą, ś, ż etc.) i'm getting: Wide character in syswrite at /usr/lib/perl/5.10/IO/Handle.pm line 207.
I have tried to check if the string is valid utf8:
print utf8::is_utf8($qItem). ':' . utf8::valid($qItem)
and I did get 1:1
- so yes I do have the correct utf8 string.
I have find out that the reason could be that syswrite gets the filehandler to the queue file which is not aware to be a :utf8 encoded file.
Am I right? If so is there any way to force File:Queue to use the :utf8 file handler? Maybe the File:Queue is not the best choice - should I use sth else to create FIFO queue between two perl scripts?