use strict; use warnings; use Devel::Peek; my $x = ""; Dump $x; ddd($x); print $x; Dump $x; use Inline Config => BUILD_NOISY => 1, ClEAN_AFTER_BUILD =>0; use Inline 'C' => 'Config' => ccflagsex => "-g"; use Inline 'C' => <<'CODE'; int ddd(SV* x){ char* dx = "dddddd\n"; printf("string dx is %p \n", dx); // You have to use sv_use* family, since these functions free the previous PV in SV first for you, but don't use sv_usepvn otherwise perl will realloc pv. sv_usepvn_flags(x, dx, 8, SV_HAS_TRAILING_NUL); // Thanks ikegami, must set LEN to 0, otherwise, perl will try to free SV when leave scope. SvLEN_set(x, 0); return 0; } CODE