Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

creamygoodness's scratchpad

by creamygoodness (Curate)
on Feb 08, 2006 at 18:55 UTC ( [id://528899]=scratchpad: print w/replies, xml ) Need Help??

Invoking SvPVutf8 on $1 while in the midst of m//g seems to produce a nasty interaction.

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); }

Output:

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 $
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-20 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found