use strict; use warnings; use Inline C => <<'END_C'; void test1(SV *sv) { STRLEN len; char *ptr = SvPVutf8(sv, len); warn("%s\n", ptr); } void test2(SV *sv) { STRLEN len; char *ptr = SvPVutf8(sv, len); warn("%s\n", ptr); SvPOK_off(sv); } END_C warn "SvPVutf8 messes up the behavior of \$1.\n"; my $foo = "a b c"; while ( $foo =~ /(\w)/g ) { warn "$1\n"; test1($1); } warn "Invoking SvPOK_off solves the problem.\n"; while ( $foo =~ /(\w)/g ) { warn "$1\n"; test2($1); } #### marvin@smokie:~/perltest $ bleadperl dollar_one_svpvutf8.pl SvPVutf8 messes up the behavior of $1. a a a a a a Invoking SvPOK_off solves the problem. a a b b c c marvin@smokie:~/perltest $