in reply to Re^2: Extending & Embedding Perl simultaneously: How to share a scalar between perl callback sub and main body?
in thread Extending & Embedding Perl simultaneously: How to share a scalar between perl callback sub and main body?

Thanks for all the comments!

Apologies for typo in the code sample. I tried prefixing "our", but that didnt change the result.

As almut said, I am using a cloned interpreter and the perl sub/callback is executed in the cloned interpreter context. So, is the problem in how I'm cloning it? Or does cloning by definition mean, I cannot "share". Here is a post describing how I've done the embedding.

One "crude" way I can think of is to implement a "shared memory" API on C side to save/retrieve data between the subs and main. Perhaps CPAN has modules like this already..but I'm really hoping there is a more "natural" solution.

http://markmail.org/thread/cjbhybjfikuirvud

http://markmail.org/thread/inetppjegt5iecl5

  • Comment on Re^3: Extending & Embedding Perl simultaneously: How to share a scalar between perl callback sub and main body?

Replies are listed 'Best First'.
Re^4: Extending & Embedding Perl simultaneously: How to share a scalar between perl callback sub and main body?
by perlmonk1729 (Acolyte) on Dec 03, 2009 at 08:47 UTC
    Hi All,

    Hoping to get some pointers as I am really stuck here. I couldnt yet figure out the cause of the problem.

    I also couldnt find any package in CPAN to "hack" around this issue : most sharing related packages seem really geared toward multi-process, distributed sharing or persistance. None that are simple/for my case. I guess I've to write my own workaround? :(

    Thx

    ps: I'm in Asian timezone, hence the "delays" in responding back to posts.

      The problem is that unless someone has encountered your exact scenario--which is quite unlikely--the only way to find a solution would be to try a few things out.

      But in order to try things out, anyone considering doing so would have to try and reproduce your code from your description. And that's a hard thing to do and rather expecting to much of us. cdarke had a good attempt, but fell short.

      If you want further help, you're much more likely to get it if you would post a minimal, runnable example that can be downloaded and tried out. Perhaps you could start with cdarke's example and modify it to reflect your requirements to the point where it produces the error message your getting.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Thanks for the comments BrowserUk. I understand. I was hoping my situation wasnt so unique..that cant be good for my project long term (ie more surprises probably lay ahead). Anycase, I'll post a full sample shortly. I'm not comfortable with XS (used SWIG), so may take a bit.