in reply to Re: Re: Answer: how do i push an array into the perl stack in C prog before calling perl_call_pv
in thread how do i push an array into the perl stack in C prog before calling perl_call_pv

hi, in that case how wld the perl subroutine demarcate the two arrays arr1 & arr2. ie if we have arr1=(1,2) and arr2=(3,4) how wld the perl subroutine know that arr1's contents ends at 2 and arr2 ends at 4 as i would be doing only XPUSH of 1,2,3,4 before calling the sub through perl_call_pv. any help would be greatly appreciated . thank you ragu
  • Comment on Re: Re: Re: Answer: how do i push an array into the perl stack in C prog before calling perl_call_pv

Replies are listed 'Best First'.
(tye)Re3: Answer: how do i push an array into the perl stack in C prog before calling perl_call_pv
by tye (Sage) on May 08, 2001 at 18:16 UTC

    That is the point: It wouldn't. I suggest you read more about Perl if you think that it would. For example, if you have Perl installed, type "perldoc perlsub" for lots of information about Perl subroutines and how to call them.

            - tye (but my friends call me "Tye")
      hi,
      sorry for my persistence.i'm kind of stuck because of this and i need to find a solution. though i am not a perl expert,i do know about basics of todays trend of languages. using reference mechanism i can do this in perl(below).Is it possible to pass this reference if i were to call this sub 'call()' from a C prog after XPUSH'ing the arguments into the perl stack. please do reply.
      #begin #!/bin/perl @xyz=(abcdefghij,xyz,sdfakjsadfk); @abc=(123,345,567); &call("string1",\@xyz,\@abc,"string2"); sub call { $w=$_[0]; $x=$_[1]; $y=$_[2]; $z=$_[3]; foreach (@$x){ print "$_ "}; print "\n"; foreach ($w){ print "$_ "}; print "\n"; foreach (@$y){ print "$_ "}; print "\n"; foreach ($z){ print "$_ "}; print "\n"; } #end
      thank you
      ragu

      Edit by tye

        Which takes us back to what I said first: You can make a reference to the array and XPUSH that. See "perldoc perlguts" under the heading "References" for more information.

        Sorry, I don't know how to make a reference off the top of my head, but I doubt that it is terribly difficult.

                - tye (but my friends call me "Tye")