Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 lurking in the Monastery: (9)
As of 2024-10-10 19:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (45 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.