I don't think your problem is specifically related to Unicode. "\040" is an escape sequence that expands to character 32 in your charset, which is space in both ASCII and UTF-8.
$x, the value Perl's parser had processed, reflect the string literal. $p, the value you read off disk verbatim, does not. On Sun, Jun 28, 2009 at 9:00 AM, Peter Gordon<[email protected]> wrote: > 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? > > Thanks, > > Peter > > > #! /usr/bin/perl > > use strict ; > use warnings ; > > my $x = "//10.39.43.1/사과를\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 > //10.39.43.1/사과를\040좋아해요 > DB<2> p $x > //10.39.43.1/사과를 좋아해요 > DB<3> > > _______________________________________________ > Perl mailing list > [email protected] > http://mail.perl.org.il/mailman/listinfo/perl -- Gaal Yahas <[email protected]> http://gaal.livejournal.com/ _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
