in reply to Re: Passing a very large string by reference to a c library
in thread Passing a very large string by reference to a c library

This stems from my (mistaken) belief that perl copies variables on subroutine calls. It appears that this is not true ;-). It seems that the copying may take place during the standard assignment in the subroutine body which can be avoided with a little thought. eg:

&find_index($key, \$bigstring);

sub find_index {
  my ($key, $rbigstring) = @_;

becomes:
&find_index($key, $bigstring);

sub find_index {
  my ($key) = $_[0];
  my ($rbigstring) = \$_[1];
 

This has the added benefit of making the sub call for both c and perl the same.

Thanks for your help

dino

  • Comment on Re: Re: Passing a very large string by reference to a c library