Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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


marvin@smokie:~/perltest $ bleadperl 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?

What's my password?
Create A New User
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2017-01-19 07:16 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (168 votes). Check out past polls.