I'm puzzled with this test script:
#!perl
use strict;
use warnings;
use encoding 'utf8';
use Test::More 'no_plan';
ok('áá' =~ m/á/, 'ok direct match');
my $re = qr{á};
ok('áá' =~ m/$re/, 'ok qr-based match');
like('áá', $re, 'like qr-based match');
The three tests fail, but I was expecting that the use encoding 'utf8'
would upgrade both the literal áá
and the qr
-based regexps to utf8 strings, and thus passing the tests.
If I remove the use encoding
line the tests pass as expected, but I can't figure it out why would they fail in utf8
mode.
I'm using perl 5.8.8 on Mac OS X (system version).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…