[Israel.pm] Unicode problem

Peter Gordon peter at pg-consultants.com
Sat Jun 27 23:00:45 PDT 2009

I have a Unicode string in a program, and a unicode string on in a file,
and the strings do not match as equal.

In the example below, save the program as file /tmp/a2.pl.
Run the program /tmp/a2.pl. The program reads itself and extracts the
unicode string.

The strings do not match.

When displayed, the strings are not the same.

What do I need to do to get them to display and match as equal?



#! /usr/bin/perl

use strict ;
use warnings ; 

my $x = "//사과를\040좋아해요" ; 

open(my $fh, "<:utf8", "/tmp/a2.pl");
local $/ = undef ; 
my $y = <$fh> ; 
close $fh ; 

my ($p) = $y =~ m!"(//.*?)"! ;
print $p,"\n"; 
print $x,"\n"; 

if ($p eq $x) { 
    print "EQUAL\n" ; 
} else { 
    print "NOT EQUAL\n" ; 

  DB<1> p $p
  DB<2> p $x
//사과를 좋아해요

More information about the Perl mailing list