I'm learning. Probably not pretty... (please suggest improvements), but it
works. Here is an example of modifying a scalar passed as a parameter:

use Inline C => DATA;
 
my $text = 123456;
my $length = append_string($text);
print "text: [$text], length: $length\n";
1;

__DATA__
__C__
#include <stdio.h>

int append_string (SV* sv_value) {
  char *my_value;
  int length;

  length = SvCUR(sv_value);
  my_value = (char *)malloc(length);
  strcpy(my_value, SvPV_nolen(sv_value));
  sv_setpvf(sv_value, "hello %s", my_value);
  free(my_value);

  return SvCUR(sv_value);
}

Reply via email to