The task is to transfer a list of huge strings to subroutibe, but avoiding their copying on transfer. Say I have a reference named $ref
pointing to the very large string. Also let's have f($)
subroutine accepting a single argument. There are no problem to transfer this string to f
:
f($$ref); # data pointed by $ref is not copied to temporary value here
Really I have not a single string, but list of them, let's assign them to @a
:
my @a = ($ref_1, $ref_2, $ref_3, ...);
Now the problem would be solved by
f(map {$$_} @a);
but map
does copy every dereferenced item from @a
, and then transfer those copied instances to f
.
I have no control on f
since it actually is the method from CPAN module.
So is there possible to solve the task? Much thanks in advance.