Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

creamygoodness's scratchpad

by creamygoodness (Curate)
on Feb 08, 2006 at 18:55 UTC ( #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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2014-12-29 16:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (193 votes), past polls