Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:00:45+00:00 2026-05-28T16:00:45+00:00

The task is to transfer a list of huge strings to subroutibe, but avoiding

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T16:00:46+00:00Added an answer on May 28, 2026 at 4:00 pm

    Yes, ‘map’ can be a bit annoying in the way it always copies.

    You can dereference a all elements from entire list into an array, without copying, using Data::Alias::deref.

    Assuming @a is an array of references, and you want to call a function f() with an argument list which is the result of dereferencing those references, then you can do

    use Data::Alias qw( alias deref );
    
    f(deref @a);
    

    (Note that Data::Alias exists as a distro module for (for example) Ubuntu (libdata-alias-perl), so you should be able to use it even if you can’t use CPAN directly.)

    In fact, if you’re dealing with a lot of large string objects and minimising copying is a concern, you might want to use Data::Alias more extensively. In fact, once you have Data::Alias in your programming arsenal, you might find you don’t need to store the data in your array as references at all.

    Say, your data comes to you one (huge) value at a time, and you want to put those values into an array. Whereas you might currently do

    push @a, \$value;
    

    you could change that to

    alias push @a, $value;
    

    If you have two lists (of huge elements) that you want to make into one big array, you can do this

    alias my @one_big_array = (@a, @b);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a task to transfer text files from one pc to another using
Task at hand — I have three versions of some code, developed by different
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and
Task: I have a camera mounted on the end of our assembly line, which
The task is pretty simple, but I've not been able to come up with
I have been asked to develop a highly secure B2B File Transfer system between
Task: transfer a server side binary tree to client. I got this task in
I've the task to transfer small binary messages (1 or 2 kb long) between
I am creating a basic data transfer task using TSQL where I am retrieving
I have a task at hand of creating some kind of logic for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.