in reply to How to return Hashref from one script to another script?

Your child script returns a hash reference .. how? I wonder if you mean subroutine, not script. A reference is an address in memory which will become invalid at the conclusion of the script because perl will release all memory at the end of the program. In any event, if you could share your source code, it would help.

  • Comment on Re: How to return Hashref from one script to another script?

Replies are listed 'Best First'.
Re^2: How to return Hashref from one script to another script?
by sriram83.life (Acolyte) on Mar 12, 2014 at 17:26 UTC
    Thanks mate.Now i got it.All references will get clear as soon as script dies.I will write a seperate XML generating module and import that into my child script to produce xml output.I am not aware of how scripts communicate using perlipc.I just called child script from my parent script as follows.
    my $hashref = `iim.pl -i $inputfile`;
    I expected that output of iim.pl could be a hashref.Now, i get it.We can collect only STDOUT of child script in the parent script.Am i right?
    Thanks,
    Sriram

      As long as you start the child script as you are, yes, the communication directly between parent and child is limited to STDOUT and possibly STDERR. There are many ways to communicate indirectly: have the child write the xml data out to a file which the parent will open, for instance. In your case, passing the XML directly back to the parent seems the best idea.

      perlipc discusses inter-process communication, exchanging messages between independent processes running at the same time. I've read that myself, but I can't claim to understand how it works. Threads are another way to accomplish the same thing and communication between is easier. See these tutorials for more information.