sajanagr has asked for the wisdom of the Perl Monks concerning the following question:

Hi

This is to all the Perl monks out there.

I have wrote a function to add elements passed in a file sample.pl and converted this file into sample.exe using Perl2Exe.

Now, I have another file where I am trying to call this executable by 'System' command.

This works fine when I give scalar values, but I am trying to pass arrays and hashes too, which I am not able to achieve.

I tried to pass the reference of the array, but only the base value of the array is taken.

Can anyone help me with this issue ? Any help and suggestion is highly appreciated.

  • Comment on Passing arguments as array and hash with executable Perl file

Replies are listed 'Best First'.
Re: Passing arguments as array and hash with executable Perl file
by Corion (Patriarch) on May 12, 2010 at 07:43 UTC

    system (and common operating systems) can only pass strings to other programs. The easiest approach is to serialize your data using Storable or Data::Dumper to a file and then to pass the name of that file to the other program and load the data from there, using Storable or do. Alternatively, you could incorporate the code of the second program into the first program, maybe as a module.